Saturday, February 7, 2009

Syntax highlighting and source code publishing in Blogger


Been trying to publish some JavaScript Code in blogger and not having much fun so I found these two links which may be useful.

http://pleasemakeanote.blogspot.com/2008/06/posting-source-code-in-blogger.html which provides syntax highlights.

http://codeassist.blogspot.com/2008/08/display-html-php-or-javascript-code-in.html which converts your code into escaped code for publishing. This item links to his code converter at http://www.psd2markup.com/display-html-php-javascript-code-in-blogger.html
Update:Just posted a blog on Ubiquity and created a new verb to do this. http://blog.frank-web.org/2009/02/ubiquity-is-must-have.html


It took me a bit to get the syntax highlighter working as the Blogger template editor kept converting the quotes in the last javascript to ' which was a pain, so I got around it by having those two lines in another script file on my server. I think you also have to load the specific JS files for each type of code you need.

Here is my test code for highlighting

<script type="text/javascript">
alert('test syntax highlighter');
</script>



<?php
echo 'test syntax highlighter';
?>

No comments:

Post a Comment