prinzipiell so:
Code:
function latex( $string ) {
//wenn $string leer, retourniere falsch
if ( empty( $string ) )
return false;
$nlsearch = array( "rn" , "r" );
$nlreplace = "n";
$string = str_replace( $nlsearch , $nlreplace , $string );
//escape special chars
$tobeescaped = array( "\" , """ , "$" , "&" , "%" , "#" , "_" , "{" , "}" , "^" , "~" , "<" , ">");
//replace:
$escaped = array( "verb==" , ""'" , "$" , "&" , "%" , "#" , "_" , "{" , "}" , "verb=^=" , "verb=~=" , "verb=<=" , "verb=>=");
//escape 'em
$string = str_replace( $tobeescaped , $escaped , $string );
//array with all strings wich have to be replaced
//frage: was gibts außer t noch für seitenvorschubssequenzen?
$tobereplaced = array( "ä" , "ö" , "ü" , "Ä" , "Ö" , "Ü" , "ß" );
//array with their replacements
$replacements = array( ""a" , ""o" , ""u" , ""A" , ""O" , ""U" );
//replace 'em
$string = str_replace( $tobereplaced , $replacements , $string );
//simple text formats
$tagspattern = array( "%(.*)%Ui" , "%(.*)%Ui" , "%(.*)%Ui" );
//their replacements
$tagsrepl = array( " extit{ $1 } " , " extbf{ $1 } " , " uline{ $1 } " );
//replace 'em
$string = preg_replace( $tagspattern , $tagsrepl , $string );
//return it
return $string;
}
ist aber noch betastatus weil noch nicht wirklich getestet...
es gehen halt schon simple sachen wie
[b] bold
[i] italic
[u] underline