October 16, 2008

alternative syntax highlighting

an alternative way to do syntax highlighting is using the dojo toolkit. dojo toolkit is a javascript library.

add this code to your template in the same place described in the previous post.

<link href='http://o.aolcdn.com/dojo/1.2/dojox/highlight/resources/highlight.css' rel='stylesheet'/>
<link href='http://o.aolcdn.com/dojo/1.2/dojox/highlight/resources/pygments/default.css' rel='stylesheet'/>
<script djConfig='parseOnLoad: true' src='http://o.aolcdn.com/dojo/1.2/dojo/dojo.xd.js'/>
dojo.addOnLoad(function() {

put all your code inside <pre> and <code> blocks and use a <code class="lang"> to define the language for the code block. valid values for lang are:
  • cpp
  • css
  • delphi
  • django
  • html
  • javascript
  • python
  • sql
  • xml
unfortunately, since php is not supported, i probably won't end up using this option. also, feel free to suggest any other options that i might like better than the 2 i've found so far.

October 9, 2008

first post - syntax highlighting

there are probably hundreds of posts about this already but here's another one for your pleasure...

to get syntax highlighting in your blogger, click on the 'copy to clipboard' link below and then go to Layout->Edit HTML and paste the code right before the </body> tag at the end of the template:

<link href='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>

<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shCore.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushCSharp.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushPhp.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushJScript.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushJava.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushVb.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushSql.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushXml.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushDelphi.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushPython.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushRuby.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushCss.js'/>
<script class='javascript' src='http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shBrushCpp.js'/>
<script class='javascript'>

dp.SyntaxHighlighter.ClipboardSwf = 'http://syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/clipboard.swf';

some posts that i read suggested that you needed to download the SyntaxHighlighter library and host it somewhere but since you can link to the SyntaxHighlighter files directly in the googlecode svn, then you don't need to get your own copy of the files hosted somewhere. i've linked to version 1.5.1 but if you were really daring, you might even link to the trunk!

a little bit of background for this blog
i've been working with the dojo toolkit, zend framework and doctrine for a few months now and just wanted to share some of the things i've learned and also use this blog as a placeholder that i can refer back to also.

a little bit of background about me
i'm an australian who lives in the usa. i moved here in 2000 and i married my wife in august 2007. my wife is pregnant and we have a baby due in january 2009. i went to university from 1993 to 1998 and graduated with a bachelor of electrical engineering and a bachelor of information technology. since moving to america in 2000, i have been touring with bands doing sound. at the moment, i work for tobymac and on the side i'm working on web development. i hope to have a fancy looking web app up and running soon...

stay tuned for further details.