This page was created to keep track of changes to the wiki's syntax highlighting software. If I don't keep a log, I'll end up redoing it differently every time! --NCarter 16:30, 8 December 2008 (PST)
I have been working on the wiki's syntax highlighting and have fixed several problems, some of which have been annoying me for a long time:
- Tabs are now automatically rendered as four spaces instead of eight. To do this, I changed $header_type to GESHI_HEADER_DIV in extensions/geshi.php and set $tab_width to 4. This means that syntax highlighted source code is now output in a div instead of a pre element.
- The syntax highlighter no longer tries to highlight other random divs that it finds in the page source. This was caused by the presence of "div" in the list of 'languages' in wiki/extensions/GeshiHighlight.php. Removing it from the list fixed the problem.
C-style comment closures */ which appear at the beginning of a line get turned into a ul bullet, and in some cases the italic comment style leaks onto the following lines. This is due to MediaWiki trying to interpret the asterisk as list formatting in its usual way. A bit of experimentation suggests the following:
- Turning on line numbers fixes it but looks awful and messes up the style for the rest of the line. Might be OK with better styling for line numbers.
- It might be possible to fix it by editing geshi.php to insert an empty element at the beginning of every line.
Until I come up with a solution, contributors will have to either put something before the asterisk (a space is fine) or to use // comments.
Fun stuff for future consideration
You can add <LANGUAGE> to $header_content in geshi.php to have it automatically display the language used for each code block. Given some nice styling that sets it apart from the rest of the block, this could be quite useful.
If you need to flush the page cache for the entire wiki, resaving LocalSettings.php does the trick. You can flush single pages by adding &action=purge to the end of the page's URL.