Sunday, April 02, 2006

[Note: This post shows up in Planet Scheme with extra line breaks. If you know how to fix this, please send me a mail. Editing the original trying to fix the linebreak issue unfortunately tricks the Planet software to think it is a new post.]

Blogging about Scheme leads to the desire of including snippets of Scheme source. Being spoiled by the DrScheme syntax highlighting this means syntax colored snippets. Luckily Dorai Sitaram wrote some syntax coloring code for SLaTeX. This code was adapted/rewritten by Anton van Straten for the Scheme Cookbook. Using this this code I have put together a little servlet Paste Scheme which lets you submit a scheme snippet and returns XHTML ready to paste into your favorite blogging software.

The servlet source below was produced with Paste Scheme. The web.plt package haven't been submitted to PLaneT yet, since there is no documentation except for comments in the source yet.

(definestart; servlet sets up the various parameters such as; current-bindings and current-cookies, evaluates; the body expressiosns, the last of which should; evaluate to an xepxr. (servlet (report-errors-to-browsersend/finish) (html-paste-page)))

I tried www.browsershots.org to see what was wrong. At first I tried this blog and the syntax highlighting worked fine. Then I tried the Paste Scheme page. Lo and behold you were right. Not only did Safari not show any colors, but none did! It turns out the link to the stylesheet were to http://localhost/paste.css so it worked perfectly on my machine.