Du bist echt ganz schön auf Zack, das ist sehr löblich und hast meinen Respekt. Danke. Es ist leider sehr selten das sich jemand so für andere Einsetzt.
Wenn alles funktioniert dann werde ein Wiki schreiben wie man das am besten umsetzen kann. Das Syntax Highlight in Moodle 2.x.
Aber bis dahin werde ich es alles so einbauen und testen und ggf. auch nochmal nachdenken ob ich was finde. Ich hatte nämlich nur den Ansatz das man über den String ausliest ob [code ....] da steht und dann etwas gändert wird. Wäre sicherlich auch nicht die beste Möglichkeit.
LG
///// Edit
Ich habe die Änderungen vor genommen und habe im Editor selsbt ( HTML Format) das eingetragen:
[code php]
if (substr($source, 0, 2) == "\r\n") {
$source = substr($source, 2);
} elseif (substr($source, 0, 1) == "\n") {
$source = substr($source, 1);
}
if (substr($source, -4) == "\r\n\r\n") {
$source = substr($source, 0, -2);
} elseif (substr($source, -2) == "\r\n") {
$source = substr($source, 0, -2);
} elseif (substr($source, 0, -1) == "\n") {
$source = substr($source, 0, -1);
}
// Stuff that might be moved into the config
$insidepadding = '.75em';
$is_ie = false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE');
$geshi =& new GeSHi($source, $language);
$geshi->set_encoding('utf-8');
$geshi->set_overall_style("margin:0 1em;border:1px solid #ccc;background-color:#f0f0f0;padding-left:{$insidepadding};");
// To make things look similar in IE...
$fontfamily = 'monospace';
$fontsize = '110%';
$linenumberfontsize = '';
if ($is_ie) {
$fontfamily = "'Courier New', monospace";
$fontsize = '100%';
$linenumberfontsize = 'font-size: 90%;';
}
[/code]
Die Ausgabe allerdings ist dann folgende:
</p>
<p>if (substr($source, 0, 2) == "\r\n") { $source = substr($source, 2); } elseif (substr($source, 0, 1) == "\n") { $source = substr($source, 1); } if (substr($source, -4) == "\r\n\r\n") { $source = substr($source, 0, -2); } elseif (substr($source, -2) == "\r\n") { $source = substr($source, 0, -2); } elseif (substr($source, 0, -1) == "\n") { $source = substr($source, 0, -1); } // Stuff that might be moved into the config $insidepadding = '.75em'; $is_ie = false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'); $geshi =& new GeSHi($source, $language); $geshi->set_encoding('utf-8'); $geshi->set_overall_style("margin:0 1em;border:1px solid #ccc;background-color:#f0f0f0;padding-left:{$insidepadding};"); // To make things look similar in IE... $fontfamily = 'monospace'; $fontsize = '110%'; $linenumberfontsize = ''; if ($is_ie) { $fontfamily = "'Courier New', monospace"; $fontsize = '100%'; $linenumberfontsize = 'font-size: 90%;'; }</p>
<p>
Die Ausgabe nach der Eingabe über das HTML Format (Also dieses PopUp)
sieht auch nicht viel versprechender aus:
if (substr($source, 0, 2) == "\r\n") { $source = substr($source, 2); } elseif (substr($source, 0, 1) == "\n") { $source = substr($source, 1); } if (substr($source, -4) == "\r\n\r\n") { $source = substr($source, 0, -2); } elseif (substr($source, -2) == "\r\n") { $source = substr($source, 0, -2); } elseif (substr($source, 0, -1) == "\n") { $source = substr($source, 0, -1); } // Stuff that might be moved into the config $insidepadding = '.75em'; $is_ie = false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'); $geshi =& new GeSHi($source, $language); $geshi->set_encoding('utf-8'); $geshi->set_overall_style("margin:0 1em;border:1px solid #ccc;background-color:#f0f0f0;padding-left:{$insidepadding};"); // To make things look similar in IE... $fontfamily = 'monospace'; $fontsize = '110%'; $linenumberfontsize = ''; if ($is_ie) { $fontfamily = "'Courier New', monospace"; $fontsize = '100%'; $linenumberfontsize = 'font-size: 90%;'; }
Da muss noch irgendwo der Wurm drinn sein. aber ich werde weiter versuchen.
