Beispiel #1
0
	public static function process($strHTML)
	{
		$html = $strHTML;
		
		//$arr = Wiki2html::get_pres('<pre class="brush: js">p111</pre>...<pre class="brush: css">p222</pre>');
		//var_dump($arr);
		$arr = Wiki2html::get_pre_tags($html);
		for ($i = 0, $cnt = count($arr); $i < $cnt; $i++) {
			$html = str_replace(
						$arr[$i]['pretag'].$arr[$i]['content'].'</pre>',
						'!pre'.$i.'!',
					$html);
		}
		
		// Wiki2html Parser
		$html = html_entity_decode($html);
		$html = str_replace('&ndash;','-',$html);
		$html = str_replace('&quot;','"',$html);
		$html = preg_replace('/\&amp;(nbsp);/','&${1};',$html);				
		$html = convertTables($html);
		$html = simpleText("\n".$html);
		
		$tmp = preg_match_all("/!pre(\d)!/s", $html, $patterns);
		//var_dump($patterns);
		for ($i = 0, $cnt = count($patterns[1]); $i < $cnt; $i++) {
	    	$precontent = html_entity_decode($arr[$i]['content2']);
            $precontent = str_replace('<', '&lt;', $precontent); // to prevent output <?php
            $precontent = str_replace('>', '&gt;', $precontent);
            $html = str_replace('!pre'.$i.'!',
							"\n".$arr[$i]['pretag'].$precontent.'</pre>', $html);
		}
						
		return $html;
	}
<?php

//include("table-converter.inc.php");
include "parseRaw.inc.php";
if (empty($_GET['n'])) {
    $_GET['n'] = 1;
}
$text = file_get_contents("table-example-" . $_GET['n'] . ".txt");
echo convertTables($text);
Beispiel #3
0
function parseRaw($title, $page)
{
    putMilestone("ParseRaw start");
    $text = getPartBetween($page, '<text xml:space="preserve">', '</text>');
    $html = $text;
    //echo "<!-- " . wordwrap($text,120,"\n",1) . " -->";
    // re-html
    $html = html_entity_decode($html);
    $html = str_replace('&ndash;', '-', $html);
    $html = str_replace('&quot;', '"', $html);
    $html = preg_replace('/\\&amp;(nbsp);/', '&${1};', $html);
    $html = str_replace('{{PAGENAME}}', $title, $html);
    // Table
    $html = convertTables($html);
    $html = simpleText($html);
    putMilestone("ParseRaw done");
    return $html;
}