${1}',$html);
// emphasized
$html = preg_replace('/\'\'([^\'\n]+)\'\'?/','${1}',$html);
//interwiki links
$html = preg_replace_callback('/\[\[([^\|\n\]:]+)[\|]([^\]]+)\]\]/','helper_interwikilinks',$html);
// without text
$html = preg_replace_callback('/\[\[([^\|\n\]:]+)\]\]/','helper_interwikilinks',$html);
//
//$html = preg_replace('/{{([^}]+)+}}/','Interwiki: ${1}+${2}+${3}',$html);
$html = preg_replace('/{{([^\|\n\}]+)([\|]?([^\}]+))+\}\}/','Interwiki: ${1} » ${3}',$html);
// Template
//$html = preg_replace('/{{([^}]*)}}/',' ',$html);
// categories
//$html = preg_replace('/\[\[([^\|\n\]]+)([\|]([^\]]+))?\]\]/','',$html);
$html = preg_replace('/\[\[([^\|\n\]]{2})([\:]([^\]]+))?\]\]/','Translation: ${1} » ${3}',$html);
$html = preg_replace('/\[\[([^\|\n\]]+)([\:]([^\]]+))?\]\]/','Category: ${1} - ${2}',$html);
// image
$html = preg_replace('/\[\[([^\|\n\]]+)([\|]([^\]]+))+\]\]/','Image: ${0}+${1}+${2}+${3}',$html);
//links
//$html = preg_replace('/\[([^\[\]\|\n\': ]+)\]/','${1}',$html);
$html = preg_replace_callback('/\[([^\[\]\|\n\': ]+)\]/','helper_externlinks',$html);
// with text
//$html = preg_replace('/\[([^\[\]\|\n\' ]+)[\| ]([^\]\']+)\]/','${2}',$html);
$html = preg_replace_callback('/\[([^\[\]\|\n\' ]+)[\| ]([^\]\']+)\]/','helper_externlinks',$html);
// allowed tags
$html = preg_replace('/<(\/?)(small|sup|sub|u)>/','<${1}${2}>',$html);
$html = preg_replace('/\n*<br *\/?>\n*/',"\n",$html);
$html = preg_replace('/<(\/?)(math|pre|code|nowiki)>/','<${1}pre>',$html);
$html = preg_replace('/<!--/','',$html);
// headings
for($i=7;$i>0;$i--){
$html = preg_replace(
'/\n+[=]{'.$i.'}([^=]+)[=]{'.$i.'}\n*/',
'
".++$i.": ".htmlspecialchars($line).""; $line = str_replace("position:relative","",$line); $line = str_replace("position:absolute","",$line); if(substr($line,0,2) == '{|'){ // inner table //echo "
beginning inner table #$innertable
"; $innertable++; } $innertabledata[$innertable] .= $line . "\n"; if($innertable){ // we're inside if(substr($line,0,2) == '|}'){ $innertableconverted = convertTable($innertabledata[$innertable]); $innertabledata[$innertable] = ""; $innertable--; $innertabledata[$innertable] .= $innertableconverted."\n"; } } } return $innertabledata[0]; } function convertTable($intext){ $text = $intext; $lines = explode("\n",$text); $intable = false; //var_dump($lines); foreach($lines as $line){ $line = trim($line); if(substr($line,0,1) == '{'){ //begin of the table $stuff = explode('| ',substr($line,1),2); $tableopen = true; $table = "".simpleText($stuff[0]); else $table .= "\t\t | ". simpleText($stuff[1]); $tdopen = true; } } else if(substr($line,0,1) == '!'){ // th $stuff = explode('| ',substr($line,1),2); if($thopen) $table .="\n"; if(count($stuff)==1) $table .= "\t\t | ".simpleText($stuff[0]); else $table .= "\t\t | ".
simpleText($stuff[1]);
$thopen = true;
}else{
// plain text
$table .= simpleText($line) ."\n";
}
//echo "".++$i.": ".htmlspecialchars($line).""; //echo " Table so far: ".htmlspecialchars($table).""; } if($thopen) $table .=" | \n";
if($tdopen)
$table .="\n";
if($rowopen)
$table .="\t
---|
Table at the end:
".htmlspecialchars($table).""; //echo $table; return $table; }