Home > IT Architecture, Programming > Small fix to Google Syntax Highlighter for WordPress

Small fix to Google Syntax Highlighter for WordPress

August 15th, 2010

1.Where to put <pre></pre>

If you put source file in the 'Virsual' mode of your wordpress editor,you should then change to 'HTML' mode and enclose the source code with <pre></pre>.

2.About <pre> name='code'(use <pre lang='code'> to substitute <pre name='code'>)

By defualt,Google Syntax Highlighter for WordPress use <pre name='code'> to declare it's css's beginning.However,you'll find the 'name' attribute lost when you switching from Virsual to HTML.We can solve the problem by using the W3C standard attribute of <pre> tag,that is <pre lang='code'>.

Here are the steps:

Find wp-content/plugins/google-syntax-highlighter/Scripts/shCore.js,locate to line 364,substitute
<pre class="html" lang="code">if(_73[i].getAttribute("name")==_71){</pre>
<pre class="html" lang="code">if(_73[i].getAttribute("lang")==_71){</pre>
And that's all about the revision.Afterwards,use <pre lang="code" class="..."> when you want to highlight your code.

Good Luck!

Comments are closed.