WordPress

SyHi

Minimalistic Syntax Highlighter plug-in for WordPress which also makes sure code can still be copied and pasted into your favourite compiler!

This plug-in is totally designed for developers.

You know, that sort of people who post code snippets in their blog regularly and hardly use the Visual Editor, because they write the HTML themselves. But they don't like WordPress messing with their quotes and dashes, so this plug-in makes sure no one touches one of their lovingly crafted lines of code.

It's also very minimalistic - less than 10k, not counting the GeSHi library which is also included.

In addition, it's also lazy. It will try to avoid doing as much work as possible. That is good, because it will not eat resources like other plug-ins out there.

Download

You can install SyHi from within your blog plugins admin page. Search for SyHi! Or you can also download a zip file from the plug-in page at the Plugins directory/

How to use it

Whenever you want to post some syntax highlighted code, surround it with <code lang="language"></code>. That's it.

Example:

<code lang="php">
class HelloWorld()
{
    public function __construct()
    {
        echo "This is an unnecessarily long version of Hello World";
    }
}
</code>

gets you


class HelloWorld()
{
    public function __construct()
    {
        echo "This is an unnecessarily long version of Hello World";
    }
}

The 'lang' attribute can be entirely omitted. You will get whitespace, quotes and dashes preservation... but no highlighting.

When entering the lang attribute in the code blocks, make sure the value you enter is exactly one of the languages in the list below, or the highlighting will resort to a simple preformatted text.

Notes

  • php5 and WP2.8.5 or higher are required. The plug-in has not been tested with older configurations.
  • Be warned: there isn't any options page (yet!). The plug-in can simply be activated or deactivated.
  • This plug-in can beautify snippets in pretty much every programming language you can think of, thanks to the huge language support provided by GeSHi (the highlighting library).
    • Syntax files are in libs/geshi/.
    • Currently supported languages: 4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, c_mac, cmake, cobol, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, eiffel, email, erlang, f1, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, kixtart, klonec, klonecpp, latex, lb, lisp, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle8, oracle11, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, plsql, postgresql, povray, powerbuilder, powershell, progress, prolog, properties, providex, purebasic, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, z80, zxbasic.
    • If you require syntax highlighting for a language which is not in this list, you'll have to develop your own syntax file and place it in the libs/geshi folder. What about submitting it to GeSHi when you're done? :-)

Known issues

  • You can't place code blocks inside a code block
  • If you switch to the Visual Editor while editing a post, it will mess with any code tags. The results will make you cry.

To do

Add options for...

  • ... configuring if you want to use my css sheet, your css sheet, both, or no one at all
  • ... configuring if you want to use GeSHi, or are happy with just plain preformatted text
  • ... configuring if you want to allow commenters to post syntax highlighted code snippets