【问题标题】:Problems Adding Syntax Highlighter To Blogger向 Blogger 添加语法荧光笔时出现问题
【发布时间】:2013-04-28 02:54:28
【问题描述】:

我正在尝试将语法荧光笔添加到我在 blogger 的新博客中。出于某种原因,我不断收到这些错误:

Uncaught ReferenceError: SyntaxHighlighter is not defined Uncaught

ReferenceError: XRegExp 未定义 shCore.js:123 Uncaught

TypeError: 无法读取未定义的属性“配置”

这是我的代码:

<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>

对我来说,一切看起来都正确吗?

编辑:我注意到当我更改演示中任何文件的路径时,脚本会中断并且不起作用。这根本没有任何意义......

【问题讨论】:

  • 这像this other Blogger Syntax Highlighter issue 吗?可能与您使用的模板有关?
  • 这可能是模板问题,但我使用的是基于“简单”主题的自定义模板。没有什么花哨。在您提供的链接中,所有这些问题都基于“动态视图”主题。我不知道问题是什么......
  • 我什至尝试了您提供的帖子中的解决方案。它没有用。
  • 不确定...我没有否决这个问题;)无论如何,很遗憾听到其他帖子似乎没有帮助。您是否在一个简单、单独的 HTML 文件中单独尝试过语法高亮显示(只是为了验证您的脚本行是否有效?)
  • 为什么有人投票结束这个?

标签: javascript


【解决方案1】:

我在这里按照这个方法:http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html

它可能没有使用自动加载器(因为我想阻止 http 请求),但它为我提供了一个工作示例,也许我可以让自动加载器正常工作。

谢谢。

【讨论】:

  • 这会支持https 协议吗?
【解决方案2】:

使用highlight js 的简单替代方案将非常简单,并且有许多非常有趣的视图

演示见here from the official website

<!– Syntax highlighter –>
<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 –>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2010-11-12
    • 2010-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多