目前我计划将SyntaxHighlighter添加到我的 Blogger(动态视图)。但是,我尝试了互联网上的所有方法,但仍然无法解决,包括[1] [2] [3] [4] [5] [6]。
关于如何解决这个问题的任何想法?或者为 Blogger 动态视图建议的任何替代语法荧光笔?
首先确保您将此代码包含在您的脑海中:
<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>
现在,每当您向博客文章添加代码(将它们添加到 pre 标记中)时,在每篇文章的末尾添加此 javascript(您可以通过在博客文章编辑器中切换到 HTML 选项卡来添加它)
<script type="text/javascript">
SyntaxHighlighter.highlight();
</script>
谢谢 :)
我只是找到了另一种方法来做到这一点(虽然没有直接解决问题):
使用Windows Live Writer作为 Blogger 离线编辑器。
下载并安装插件Paste As Visual Studio Code for Windows Live Writer。并用它来插入代码。
虽然它只能从 插入代码Visual Studio
,但对我来说似乎已经足够了。我的博客中的一个例子如下: