GeSHi and Pear Wiki Filter can play together

Having struggled for an age to work out how to get syntax highlighting for code blocks and the Pear wiki filter to work in harmony I thought it best to record the configuration here.

I've created an input format that allows for media wiki syntax to get headings, lists and some basic formatting using the following filters (listed in order).

  • GeSHi filter
  • PEAR Wiki Filter
  • Inline images
  • freelinking filter
  • HTML corrector
  • HTML Purifier

(I'm still tinkering with the Purifier to remove empty P elements)

The reason they are in that order is so that any code blocks are picked up first, otherwise the wiki filter converts the tags into greater and less than signs

The wiki filter is then set:

Allow HTML? not ticked - very important.

Ignore tags - div code blockcode

it has to ignore div - the GeSHi filter wraps its results in a div, which the wiki filter can then leave alone - or it adds line break tags

GeSHi filter is set to look for <code> use CSS classes and an external stylesheet and use a pre container or something adds a spurious closing div...

there are empty P elements if there are two lines preceding the code block - in the source avoid that by starting the code block on the next line after the text that introduces it.

these settings appear to work see Hiding from Mac IE5 for example

YMMV