网上下载出WordPress的插件Wp-syntax,安装并启动
在编辑文章时,切换用HTML的文本编辑方式插入以下代码<pre lang=”LANGUAGE” line=”0″>//“line为1时表示显示行号”</pre>
中间插入你的代码即可,LANGUAGE改为语言类型,例如php、java。line为0不显示行号,为1时显示.等号后面的双引号用小写。

如:<pre lang=”Lanuage” line=”1″>function sanitize_user( $username, $strict = false ) {
$strict = false;
$raw_username = $username;
$username = wp_strip_all_tags( $username );</pre>

效果如下:

function sanitize_user( $username, $strict = false ) {
	$strict = false;
	$raw_username = $username;
	$username = wp_strip_all_tags( $username );
	$username = remove_accents( $username );

支持的语言如下:abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, asp, autoit, avisynth, bash, bf, bibtex, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cil, cfdg, cfm, cmake, cobol, cpp-qt, cpp, csharp, css, d, dcs, delphi, diff, div, dos, dot, eiffel, email, erlang, fo, 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, properties, 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, whois, winbatch, xml, xorg_conf, xpp, z80

打赏作者
0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
菜单
0
Would love your thoughts, please comment.x
()
x