我正在尝试将 Syntax Highlighter 添加到我在 blogger 的新博客中。出于某种原因,我不断收到这些错误:
Uncaught ReferenceError: SyntaxHighlighter is not defined Uncaught
ReferenceError: XRegExp is not defined shCore.js:123 Uncaught
TypeError: Cannot read property 'config' of undefined
这是我的代码:
<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>
对我来说,一切看起来都是正确的?
编辑:我注意到当我更改演示中任何文件的路径时,脚本会中断并且无法运行。这根本没有任何意义......
最佳答案
我在这里采用了这种方法:http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html
它可能没有使用自动加载器(因为我想阻止 http 请求),但它为我提供了一个工作示例,也许我可以让自动加载器工作。
谢谢。
关于javascript - 将语法高亮器添加到 Blogger 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16259083/