SyntaxHighlighter不适用于Blogger动态视图?

时间:2013-12-27 12:34:13

标签: blogger blogspot syntaxhighlighter blogger-dynamic-views

目前我计划将SyntaxHighlighter添加到我的Blogger(动态视图)。但是,我尝试了互联网上的所有方法,但仍然无法解决问题,包括[1] [2] [3] [4] [5] {{3} }。

有关如何解决此问题的任何想法?或者为Blogger动态视图建议的其他语法高亮显示器?

2 个答案:

答案 0 :(得分:6)

首先确保将此代码包含在您的头脑中:

<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css">
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript">
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

现在每当您在博客帖子中添加代码(在预标签中添加它们)时,请在每篇帖子的末尾添加此javascript(您可以通过切换到博客帖子编辑器中的HTML标签添加它)

<script type="text/javascript">
 SyntaxHighlighter.highlight();
</script>

谢谢:)

答案 1 :(得分:0)

我只是找到了另一种方法(虽然没有直接修复问题):

  1. 使用 Windows Live Writer 作为Blogger离线编辑器。

  2. 下载并安装适用于Windows Live Writer的插件 Paste As Visual Studio Code 。并使用它来插入代码。

  3. 虽然它只能插入来自Visual Studio的代码,但对我来说似乎已经足够了。 my blog的示例如下:

    enter image description here