// but has since been enhanced with other WikiText support.
$output = << This is not
Lists
Term Definition
Headings
Fonts
This is in monospace
Indented Paragraphs
''this
will not work''
]
|| Heading 1 || Heading 2 | Cell a1 | Cell a2 | Cell b1 | Cell b2Result:
| Heading 1 | Heading 2 |
|---|---|
| Cell a1 | Cell a2 |
| Cell b1 | Cell b2 |
Footnotes:
[1]+ By using [1] a second time (in the first column) the footnote itself is defined. You may refer to a footnote as many times as you want, but you may only define it once on the page. Note the the [1] in the footnote links back to the first reference, if there are multiple references there will be +'s after the [1] which will link to the other references. (References which come after the footnote definition will not be linked to.)
$matches[1]", $replacements[$oldn]); } $oldn++; } if (!strlen($tmpline) || $tmpline == "\r") { // this is a blank line, send
$html .= _wikitext_set_output_mode('', ZERO_LEVEL, 0);
continue;
} else
/* phpwiki-way of protecting HTML */
// if (preg_match("/(^\|)(.*)/", $tmpline, $matches)) {
// this change is to prevent wiki table from being skipped
if (preg_match("/(^\|>)(.*)/", $tmpline, $matches)) {
// HTML mode
$html .= _wikitext_set_output_mode("", ZERO_LEVEL, 0);
$html .= $matches[2];
continue;
}
/**/
$tmpline = _wikitext_tokenize($tmpline, '<[^>]+>', $replacements, $ntokens);
/*
* 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 = _wikitext_tokenize($tmpline, '\[\[', $replacements, $ntokens);
while ($oldn < $ntokens) {
$replacements[$oldn++] = '[';
}
// Now process the [\d+] links which are numeric references
$oldn = $ntokens;
$tmpline = _wikitext_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 = _wikitext_tokenize($tmpline, '\[.+?\]', $replacements, $ntokens);
while ($oldn < $ntokens) {
$link = _wikitext_parse_and_link($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 = _wikitext_tokenize($tmpline, "!?\b(".ALLOWED_PROTOCOLS."):[^\s<>\[\]\"'()]*[^\s<>\[\]\"'(),.?]", $replacements, $ntokens);
while ($oldn < $ntokens) {
if($replacements[$oldn][0] == '!') {
$replacements[$oldn] = substr($replacements[$oldn], 1);
} else {
$replacements[$oldn] = _wikitext_link_URL($replacements[$oldn]);
}
$oldn++;
}
//escape HTML metachars
// $tmpline = str_replace('&', '&', $tmpline);
$tmpline = str_replace('>', '>', $tmpline);
$tmpline = str_replace('<', '<', $tmpline);
// %%% are linebreaks
$tmpline = str_replace('%%%', '
', $tmpline);
// \\ are also 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 (
$html .= _wikitext_set_output_mode('pre', ZERO_LEVEL, 0);
} else if (preg_match("/^(!{1,3})[^!]/", $tmpline, $whichheading)) {
// lines starting with !,!!,!!! are headings
if ($whichheading[1] == '!') {
$heading = 'h3';
} else if ($whichheading[1] == '!!') {
$heading = 'h2';
} else if ($whichheading[1] == '!!!') {
$heading = 'h1';
}
$tmpline = preg_replace("/^!+/", '', $tmpline);
$html .= _wikitext_set_output_mode($heading, ZERO_LEVEL, 0);
} else if (preg_match('/^-{4,}\s*(.*?)\s*$/', $tmpline, $matches)) {
// four or more dashes to
//
can not be contained in a
$html .= _wikitext_set_output_mode('', ZERO_LEVEL, 0) . "
\n";
if ( ($tmpline = $matches[1]) != '' ) {
$html .= _wikitext_set_output_mode('p', ZERO_LEVEL, 0);
}
} else if (preg_match('/^\|/', $tmpline, $matches)) {
// table!
if (!$istable) {
$istable = TRUE;
$html .= _wikitext_set_output_mode('', ZERO_LEVEL, 0);
// unfortunately, can't use _wikitext_set_output_mode due to add'l params
$html .= "| ", $tmpline); $tmpline = preg_replace("/\s*\|\|\s*/", " | ", $tmpline); $tmpline = " |
|---|
| ", $tmpline); $tmpline = preg_replace("/\s*\|\s*/", " | ", $tmpline); $tmpline = " |