显示效果:
1.dp-highlighter
2{}{
3 font-family: "Consolas", "Courier New", Courier, mono, serif;
4 font-size: 12px;
5 background-color: #E7E5DC;
6 width: 99%;
7 overflow: auto;
8 margin: 18px 0 18px 0 !important;
9 padding-top: 1px; /**//* adds a little border on top when controls are hidden */
10}
使用方法:下载
HighLighter1.7.rar后,将压缩包中的文件覆盖到Blog的根目录。在需要高亮显示代码的页面的<head>标签内插入:
<link type="text/css" rel="stylesheet" href="<#ZC_BLOG_HOST#>Plugin/HighLighter/SyntaxHighlighter.css"></link>
在<body>结束前插入(可根据需要进行删减):
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shCore.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushCpp.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushCSharp.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushCss.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushDelphi.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushJava.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushJScript.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushPhp.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushPython.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushRuby.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushSql.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushVb.js"></script>
<script language="javascript" src="<#ZC_BLOG_HOST#>Plugin/HighLighter/shBrushXml.js"></script>
<script language="javascript">
dp.SyntaxHighlighter.HighlightAll('code', true, true);
dp.SyntaxHighlighter.HighlightAll('code2', false, false);
</script>
覆盖上传后,文件重建。
使用代码高亮标签时,需要<textarea></textarea>标签的支持。将代码放入<textarea>之中。代码中第一行的“CSS”可以替换成你所需要的语言:
c#,javascript,vb,xml,php,sql,delphi,Python
<textarea name="code" language="css">
.dp-highlighter
{
font-family: "Consolas", "Courier New", Courier, mono, serif;
font-size: 12px;
background-color: #E7E5DC;
width: 99%;
overflow: auto;
margin: 18px 0 18px 0 !important;
padding-top: 1px; /* adds a little border on top when controls are hidden */
}
</textarea>
适用版本:ZBlog 1.7 Laputa Build 70216
源码来源:
http://code.google.com/p/syntaxhighlighter/文章来源:
http://liuleng.com/post/450.html