wordpress代码高亮插件优化
昨天发布代码的时候就发现显示总是会出错,还会使页面错乱,下了几种插件,在这个主题下都无法使用,出现错误,也不想去看代码了,最后选择了wp-syntax[1].0.9.3,下载地址:
-
http://downloads.wordpress.org/plugin/wp-syntax.0.9.3.zip
使用方法:
所要显示的代码
支持代码种类:
abap, actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic, genero, gml, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, m68k, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, per, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80
但随即又出现了问题,不支持代码自动换行,最后终于找到了解决办法,修改所用主题的CSS文件,添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | .wp_syntax { color: #100; background-color: #f9f9f9; border: 1px solid silver; margin: 0 0 1.5em 0; overflow: auto; } /* IE FIX */ .wp_syntax { overflow-x: auto; overflow-y: hidden; padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 15 : 0); } .wp_syntax table { table-layout:fixed; overflow:hidden; text-overflow:ellipsis; WORD-BREAK: break-all; WORD-WRAP: break-word; border-collapse: collapse; } .wp_syntax div, .wp_syntax td { vertical-align: top; padding: 2px 4px; } .wp_syntax .line_numbers { text-align: right; background-color: #def; width:30px; color: gray; overflow: visible; font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; } /* potential overrides for other styles */ .wp_syntax pre { margin: 0; width: fixed; float: none; clear: none; WORD-BREAK: break-all; WORD-WRAP: break-word; overflow: visible; font-size:8pt; font-family: Courier New; } |