I've just made an update to the version of
.TEXT running my blogs to
add code syntax highlighting. Rather than write my own, I incorporated
dp.SyntaxHighlighter from
Dream Projections Inc.
dp.SyntaxHighlighter is a Java script solution, so to get it to work I
had to add the right CSS and Java script references in the blog entry
pages. Drop me a line if you would like a list of changes.
With code syntax highlighting, source code in my blog now looks like:
dp.SyntaxHighlighter colorizes all code found in
textarea tags, marked with a name attribute containing value
code. Since RSS viewers will not render
textarea tags I added some code to .TEXT to convert these to
p tags when requesting blog pages as XML.
The whole thing works pretty well, except when using the design feature of the
FreeTextBox control contained in .TEXT edit pages. Switching from HTML to design mode mangles the source code in the
textarea tags. Also, any text following code in a
textarea tag is not rendered properly when editing.
Solution: Write the entire post without source code, switch to HTML mode and add the code in
textarea tags. Copy the HTML to the clipboard and then post
without switching to design mode. If the post doesn't look right edits can be made by reusing the HTML on the clipboard.