Just thought that I should share my patch for Google’s Syntax Highlighter. My patch does the following:
- Supports <code> tags (Hence won’t break XHTML)
- Fix for Wordpress (<br />) (Activate by adding this to your code: “dp.SyntaxHighlighter.WPMode();”)
- Supports of selecting tags without name (Allowing the use of “dp.SyntaxHighlighter.HighlightAll(”);”)
Apply patch below by patching with GNU patch.exe or linux gnu patch to uncompressed shCore.js
60c60
< var code = dp.sh.Utils.FixForBlogger(highlighter.originalCode).replace(/
—
> var code = dp.sh.Utils.FixForBlogs(highlighter.originalCode).replace(/
73c73
< var code = dp.sh.Utils.FixForBlogger(highlighter.originalCode)
—
> var code = dp.sh.Utils.FixForBlogs(highlighter.originalCode)
186c186
< dp.sh.Utils.FixForBlogger = function(str)
—
> dp.sh.Utils.FixForBlogs = function(str)
188c188,193
< return (dp.sh.isBloggerMode == true) ? str.replace(/|<br\s*\/?>/gi, ‘\n’) : str;
—
> if (dp.sh.isBloggerMode == true || (dp.sh.isWPMode == true && navigator.appVersion.indexOf(”MSIE”)!=-1))
> return str.replace(/|<br\s*\/?>/gi, ‘\n’);
> else if (dp.sh.isWPMode == true)
> return str.replace(/|<br\s*\/?>/gi, ”);
> else
> return str;
452c457
< var lines = dp.sh.Utils.FixForBlogger(str).split(’\n’);
—
> var lines = dp.sh.Utils.FixForBlogs(str).split(’\n’);
569a575,579
> dp.sh.WPMode = function()
> {
> dp.sh.isWPMode = true;
> }
>
613c623
< function FindTagsByName(list, name, tagName)
—
> function FindTags(list, name, tagName)
617,619c627,636
< for(var i = 0; i < tags.length; i++)
< if(tags[i].getAttribute(’name’) == name)
< list.push(tags[i]);
—
> for(var i = 0; i < tags.length; i++) {
> if (name) {
> if(tags[i].getAttribute(’name’) == name || tags[i].getAttribute(’title’) == name) {
> list.push(tags[i]);
> }
> }
> else {
> list.push(tags[i]);
> }
> }
628,629c645,647
< FindTagsByName(elements, name, ‘pre’);
< FindTagsByName(elements, name, ‘textarea’);
—
> FindTags(elements, name, ‘pre’);
> FindTags(elements, name, ‘textarea’);
> FindTags(elements, name, ‘code’);
705c723
< }
—
> }
\ No newline at end of file
