Posting Syntax-Highlighted Code to the Web, Redux
Following up on July's post, I've modified my TextMate 'rawhtml' command so it no longer generates inline <style> sections. (They may work, but AFAIK <style> should appear only in a document's <head>.)
Instead, the command now wraps its output in a div of class SourceCode, and it expects the containing web page to include an appropriate <style> section.
Here's a test to see if this works :) I've added the following CSS to the Bottled Text template HTML:
The "rawhtml" command script now looks like this:
#!/bin/sh
cat <<HTML
HTML
perl -pe 's/<\/[^>]+>/<\/span>/g' \
| perl -pe 's/<([^\/.>]+)[^>]*>/<span class="$1">/g' \
| perl -pe 's/\t/ /g'
echo "</div></div>"
cat <<HTML
HTML
perl -pe 's/<\/[^>]+>/<\/span>/g' \
| perl -pe 's/<([^\/.>]+)[^>]*>/<span class="$1">/g' \
| perl -pe 's/\t/ /g'
echo "</div></div>"
To get a realistic preview in MarsEdit, click the "Edit Template" button in the preview window and add a <style> section to the preview template for your blog. Paste in the CSS above and you're good to go.
No comments:
Post a Comment