Tuesday, January 29, 2013

Getting Syntax Highlighter Working in Blogger

This is a note to myself that the reason syntax highlighter did not work in Blogger is because I was putting my commands in the compose section. The syntax highlighter commands must be inserted in the html section.

What do you do?

You follow the directions indicated by the discussion on stack overflow at this site:http://stackoverflow.com/questions/12464924/blogger-syntaxhighlighter-doesnt-work-at-all and insert the Alex Gorbachev's syntax highlighter files into the template itself.

Then you add this tag using the appropriate brush to any section where you are going to insert code:

&pre class="brush: js" title="Example of Using Syntax Highlighter" id="codesection1"&

The code goes here followed by the ending pre tag.

&/pre&.

I had to replace the < opening bracket tag with an & to get this to show. The same is true for the & being used for the /> closing bracket.

Insert the closing "pre bracket" at the end of your code and you will be set.

Here is my small test:

var f = function () {
    return 1;
};
Here is my big test:




No comments:

Post a Comment