$html .= SetHTMLOutputMode('', ZERO_LEVEL, 0); continue; } /* If your web server is not accessble to the general public, you may allow this code below, which allows embedded HTML. If just anyone can reach your web server it is highly advised that you do not allow this. elseif (preg_match("/(^\|)(.*)/", $tmpline, $matches)) { // HTML mode $html .= SetHTMLOutputMode("", ZERO_LEVEL, 0); $html .= $matches[2]; continue; } */ ////////////////////////////////////////////////////////// // New linking scheme: links are in brackets. This will // emulate typical HTML linking as well as Wiki linking. // First need to protect [[. $oldn = $ntokens; $tmpline = tokenize($tmpline, '\[\[', $replacements, $ntokens); while ($oldn < $ntokens) $replacements[$oldn++] = '['; // Now process the [\d+] links which are numeric references $oldn = $ntokens; $tmpline = tokenize($tmpline, '\[\s*\d+\s*\]', $replacements, $ntokens); while ($oldn < $ntokens) { $num = (int) substr($replacements[$oldn], 1); if (! empty($embedded[$num])) $replacements[$oldn] = $embedded[$num]; $oldn++; } // match anything else between brackets $oldn = $ntokens; $tmpline = tokenize($tmpline, '\[.+?\]', $replacements, $ntokens); while ($oldn < $ntokens) { $link = ParseAndLink($replacements[$oldn]); $replacements[$oldn] = $link['link']; $oldn++; } ////////////////////////////////////////////////////////// // replace all URL's with tokens, so we don't confuse them // with Wiki words later. Wiki words in URL's break things. // URLs preceeded by a '!' are not linked $tmpline = tokenize($tmpline, "!?\b($AllowedProtocols):[^\s<>\[\]\"'()]*[^\s<>\[\]\"'(),.?]", $replacements, $ntokens); while ($oldn < $ntokens) { if($replacements[$oldn][0] == '!') $replacements[$oldn] = substr($replacements[$oldn], 1); else $replacements[$oldn] = LinkURL($replacements[$oldn]); $oldn++; } ////////////////////////////////////////////////////////// // Link Wiki words // Wikiwords preceeded by a '!' are not linked $oldn = $ntokens; $tmpline = tokenize($tmpline, "!?$WikiNameRegexp", $replacements, $ntokens); while ($oldn < $ntokens) { $old = $replacements[$oldn]; if ($old[0] == '!') { $replacements[$oldn] = substr($old,1); } elseif (IsWikiPage($dbi, $old)) { $replacements[$oldn] = LinkExistingWikiWord($old); } else { $replacements[$oldn] = LinkUnknownWikiWord($old); } $oldn++; } ////////////////////////////////////////////////////////// // escape HTML metachars $tmpline = str_replace('&', '&', $tmpline); $tmpline = str_replace('>', '>', $tmpline); $tmpline = str_replace('<', '<', $tmpline); // four or more dashes to
$tmpline = ereg_replace("^-{4,}", '
', $tmpline); // %%% are linebreaks $tmpline = str_replace('%%%', '
', $tmpline); // bold italics (old way) $tmpline = preg_replace("|(''''')(.*?)(''''')|", "\\2", $tmpline); // bold (old way) $tmpline = preg_replace("|(''')(.*?)(''')|", "\\2", $tmpline); // bold $tmpline = preg_replace("|(__)(.*?)(__)|", "\\2", $tmpline); // italics $tmpline = preg_replace("|('')(.*?)('')|", "\\2", $tmpline); ////////////////////////////////////////////////////////// // unordered, ordered, and dictionary list (using TAB) if (preg_match("/(^\t+)(.*?)(:\t)(.*$)/", $tmpline, $matches)) { // this is a dictionary list (
) item $numtabs = strlen($matches[1]); $html .= SetHTMLOutputMode('dl', NESTED_LEVEL, $numtabs); $tmpline = ''; if(trim($matches[2])) $tmpline = '
' . $matches[2]; $tmpline .= '
' . $matches[4]; } elseif (preg_match("/(^\t+)(\*|\d+|#)/", $tmpline, $matches)) { // this is part of a list (