终于把coolcode代码高亮插件替换为wp-syntax,wp-syntax 使用简单,显示方式简洁,视觉感官利落,对W3C也友好。
首先下载安装好wp-syntax,激活插件。
进入PHPMYADMIN替换原来coolcode的插件代码
1 2
| UPDATE `wp_posts` SET `post_content` = replace (`post_content`,'<coolcode','<pre');
UPDATE `wp_posts` SET `post_content` = replace (`post_content`,'</coolcode','</pre'); |
wp-syntax是用以下代码,设置对应参数来完成 wp-syntax 高亮代码显示的,编辑文章时,选择HTML模式下
<pre lang=”LANGUAGE” line=”1″>要显示的代码</pre>
相关参数说明:
lang=”LANGUAGE”,在language处填写你要运行的代码语言,如css、php、html、javascript等;
line=”1″,1表示代码从第一行开始显示,可以不写,不写为全部显示。
wp-syntax 还支持下面代码:
abap, actionscript, actionscript3, ada, apache, applescript, aptsources, asm, asp, autoit, avisynth, bash, bf, blitzbasic, bnf, boo, c, cmac, caddcl, cadlisp, cil, cfdg, cfm, cobol, cpp-qt, cpp, csharp, css, d, dcs, delphi, diff, div, dos, dot, eiffel, email, fortran, freebasic, genero, gettext, glsl, gml, bnuplot, groovy, haskell, hq9plus, html4strict, idl, ini, inno, intercal, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, locobasic, lolcode lotusformulas, lotusscript, lscript, lsl2, lua, m68k, make, matlab, mirc, modula3, mpasm, mxml, mysql, nsis, oberon2, objc, ocaml-brief, ocaml, oobas, oracle11, oracle8, pascal, per, pic16, pixelbender, perl, php-brief, php, plsql, povray, powershell, progress, prolog, providex, python, qbasic, rails, rebol, reg, robots, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, tcl, teraterm, text, thinbasic, tsql, typoscript, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, winbatch, xml, xorg_conf, xpp, z80
如果你嫌每次都要切换到HTML模式,手工添加麻烦的话,你还可以利用WP-Syntax Button插件添加按钮到编辑框中。