2009-04-29

Syntax testing

I have to post some python, ruby and java code in this blog. This is how the syntax highlighting is set up (documenting it for myself).

After changing the template:
  1. Copy contents of http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css and paste it into the template before ]]></b:skin>
  2. Add before </head>:
    <script language="'javascript'" src="'http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'/">
    <script language="'javascript'" src="'http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPython.js'/">
  3. Add before </body>:
    <script language="'javascript'">
    dp.SyntaxHighlighter.BloggerMode();
    dp.SyntaxHighlighter.HighlightAll('code');
    </script>
Code pasted into the blog should:
  1. Have instances of < replaced with &lt;
  2. Be placed in a section like:
<pre name="code" class="py">
...code...
</pre>



Add extra brushes as needed...


Note that the Blogger editor eats your line indentation if you edit a posting. So where indentation is important (say, in Python, but any scripts really), paste in the script as the last part of any edit action (gah!).

No comments:

Post a Comment