(编辑:jimmy 日期: 2024/12/23 浏览:2)
下面一步步介绍如何配置WLW+wordpress的代码高亮解决方案:
1.准备工作:
下载 precode code snippet manager
下载成功后得到一个名为PreCodePlugin_4.0.2.msi的文件
下载 SyntaxHighlighter2.0
下载成功后得到一个名为syntaxhighlighter_2.0.296.zip文件。
2.安装:
关闭Windows Live Writer,安装PreCodePlugin_4.0.2.msi。安装成功后启动WLW,此时在插件列表里应该出现一项名为PreCode Snippet的插件。
将syntaxhighlighter_2.0.296.zip解压缩至wordpress的活动主题目录,例如:\www\wp\wp-content\themes\lutuzhi\syntaxhighlighter
3.在header.php 中,在<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />下方添加:
复制代码 代码如下:
<script type="text/javascript" src="/UploadFiles/2021-04-02/shCore.js">02.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushBash.js">03.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushCpp.js">04.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushCSharp.js">05.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushCss.js">06.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushDelphi.js">07.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushDiff.js">08.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushGroovy.js">09.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushJava.js">10.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushJScript.js">11.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushPhp.js">12.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushPlain.js">13.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushPython.js">14.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushRuby.js">15.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushScala.js">16.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushSql.js">17.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushVb.js">18.<script type="text/javascript" src="/UploadFiles/2021-04-02/shBrushXml.js">19.<link href="styles/shCore.css" type="text/css" rel="stylesheet" />
20.<link href="styles/shThemeEmacs.css" type="text/css" rel="stylesheet" />
21.<script type="text/javascript">SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';SyntaxHighlighter.all();</script>
如此配置之后,通过Windows Live Writer插入的代码,在wordpress中可以十分优雅的显示出来。