Loading...
 
Features / Usability

Features / Usability


Aw: GeSHi as a Wiki plugin

posts: 4 Germany

> Hi All !
> One thing we'd like to be able to do is to post snippets of C#, C++, or VB code in a nicely formatted manner. At the moment we're using the CODE plugin, but we'd like to include a bit of syntax highlighting. I noticed that some work had been done to implement GeSHi, but I can't find the plugin anywhere in CVS.
>
> Does anyone know how I can implement GeSHi as a Wiki plugin? Bear in mind that I've never programmed in php so please keep things simple!

Hi, I'm using this solution for my work:
1) Edit tikiwiki-1.9.2\lib\wiki-plugins\wikiplugin_code.php from line 44

Image
Copy to clipboard
if (isset($colors)){ include_once('geshi.php'); $out.= "".geshi_highlight(decodeHTML(trim($code)), $colors, '' , true).""; }


2) copy geshi and its files to tikiwiki-1.9.2\ and tikiwiki-1.9.2\geshi

This solution works fine for HTML-Output. However with PDF I get bad results.

Regards

JMan

posts: 30

>
> Hi, I'm using this solution for my work:
> ...
> This solution works fine for HTML-Output. However with PDF I get bad results.
>
> Regards
>
> JMan

JMan, thanks for posting this enhancement. I modified your snippet to also implement the line numbering option with geshi, and force links to open in new windows. Hopefully, this will be useful to others.

Copy to clipboard
if (isset($colors)) { include_once ('lib/geshi.php'); $w_geshi = new GeSHi(decodeHTML(trim($code)), $colors, ''); $w_geshi->set_header_type(GESHI_HEADER_NONE); $w_geshi->set_link_target("_blank"); if (isset($ln) && $ln ==1) { $w_geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); } $out.= "".$w_geshi->parse_code().""; } else { if (isset($wrap) && $wrap == 1) { ...


I also opted to copy geshi.php and the /geshi subdirectory under /lib instead of the main tikiwiki directory, just my preference.

posts: 1
This is great. Thx
posts: 5

Hi all,

I've just added GeSHI support to the CODE wiki-plugin of Tikiwiki 1.10 CVS, based on your suggestions.

GeSHI now simply needs to be downloaded in lib/geshi/ to work (we can't include it in Tiki due to the license). Both stable and dev versions are supported. You can also install the php-geshi package under Debian or Ubuntu linux distributions. I hope to also have a mod, to make it even easier.

Thanks,
Nyloth.