Loading...
 
Skip to main content

Custom Share Module 0.1dev

Features / Usability

Features / Usability


geshi code beautifier

posts: 6

Hello,

Dokuwiki uses a code beautifier named geshi. It seems really intereting. It could for exemple be used within the Code plugin a lg parameter:

I've tried in lib/wiki_plugin/wikiplugin_code.php with something like:


It seems to work but unfortunately, the code is reparsed somehow, and the

<span class="kw3">

become

<span class="kw3">


Any hint with those entities problems ?
(I didn't succeed in uploading the geshi.zip file with the different languages style... There is also the code to add to the stylesheet...)

posts: 92 Germany

i guess you are looking for that:
http://qbnz.com/highlighter/forum.php?t=4

i made me a small plugin (wikiplugin_gi.php) ...
usage: {GI(lan=php) some code {GI}

include_once('geshi.php');



function wikiplugin_gi_help() {
return tra("Geshi").":{GI()}".tra("text")."{GI}";
}

function wikiplugin_gi($data, $params) {
extract ($params);
$text = str_replace('<', '', $text);
$text = str_replace('', $text);
$text = str_replace('"', '"', $text);
$text = str_replace('&', '&', $text);

$path = 'geshi/';
$language = 'php';

$geshi = new GeSHi($data, $language, $path);
$geshi->set_overall_style('color: blue;', true);

return $geshi->parse_code();

}



posts: 6

Danke schön Pi

Ifinally understood what was wrong in my code ( although it wasn't the string replace...but your idea let me go in the right direction😛)

As I have always the allowhtml, I needed to have Tiki not to read my code after geshi: just insert pp and that is it!!

Ok, so jezt ist mein Code farbenvol 😁

Copy to clipboard
function wikiplugin_code($data,$params) { require_once("lib/wiki-plugins/geshi.php"); extract($params); $geshi = new GeSHi($data, strtolower($lg), "lib/wiki-plugins/geshi"); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_classes(); $geshi->set_overall_class('code'); $data = $geshi->parse_code(); $data = ("~pp~".$data."~/pp~"); return $data; }



Thanks again
Vendo

posts: 92 Germany

danke zurück 😛

my geshi {GI,lg=powerpro} is evolving 😬

FloatingIcons

thanks again for mentioning geshi.