1

I'm trying to add Syntax Highlighter to my new blog at blogger. For some reason I keep getting these errors:

Uncaught ReferenceError: SyntaxHighlighter is not defined Uncaught

ReferenceError: XRegExp is not defined shCore.js:123 Uncaught

TypeError: Cannot read property 'config' of undefined

Here is my code:

<script src='https://xarpixels.googlecode.com/files/shAutoloader.js'/>
<script src='https://xarpixels.googlecode.com/files/shCore.js'/>
<script type="text/javascript">
    $(document).ready(function(){
      SyntaxHighlighter.config.bloggerMode = true;
      SyntaxHighlighter.autoloader(
        'js  https://xarpixels.googlecode.com/files/shBrushJScript.js',
        'php  https://xarpixels.googlecode.com/files/shBrushPhp.js',
        'sass  https://xarpixels.googlecode.com/files/shBrushSass.js',
        'sql  https://xarpixels.googlecode.com/files/shBrushSql.js',
        'xml  https://xarpixels.googlecode.com/files/shBrushXml.js',
        'css  https://xarpixels.googlecode.com/files/shBrushCss.js'
      );
      SyntaxHighlighter.all();
    });
</script>

To me, everything looks correct?

EDIT: I noticed that when I change the path to any of the files in the demo, the script breaks and doesn't work. This isn't making any sense at all...

4

2 回答 2

4

I followed this method here: http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html

It may not be using the autoloader(as I want to prevent http requests), but it gives me a working example to work from and perhaps I can get the autoloader working.

Thanks.

于 2013-04-28T15:03:19.810 回答
2

Easy alternatives using highlight js will be very easy and has many very interesting views

for demo see here from the official website

<!– Syntax highlighter –&gt;
<link href=‘//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/github.min.css’ rel=‘stylesheet’/>
<script src=‘//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js’/>
<script>hljs.initHighlightingOnLoad();</script>
<!– end Syntax highlighter –&gt;
于 2019-06-24T09:35:54.637 回答