Syntax highlighter 3.0 not working on blogspot

烈酒焚心 提交于 2019-12-24 04:51:20

问题


Syntax highlighter 3.0 is not working on my blog. I use the newest version right from the website. The issues are: If I write #include in my code, I get at the end of it. There's no text wrapping. The blog's link is http://snacksforyourmind.blogspot.com. I also checked out options but they give nothing but bloggerMode which I already enabled. All the issues are visible in the second code from top of the page. Does anybody have some idea how to fix it?


回答1:


Depending on your template, the SyntaxHighlighter JavaScript code may run before the content has loaded. In that case, changing the code to run after a short timeout should fix the problem. Try this in the <head> of your template HTML:

<script type="text/javascript">
window.setTimeout(function() {
    SyntaxHighlighter.config.bloggerMode = true;
    SyntaxHighlighter.all();
}, 10);
</script>

You can add further customisation of defaults before the call to ScriptHighlighter.all().

If you want to customise the look and feel of the SyntaxHighlighter code display, add some CSS like this:

.syntaxhighlighter code {
  font-family: Consolas !important;
  font-size: 10px !important;
}

The !important is necessary to override the SyntaxHighlighter theme definitions.



来源:https://stackoverflow.com/questions/6849890/syntax-highlighter-3-0-not-working-on-blogspot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!