');
if ($trigger_notes % 2) echo ('');
if ($trigger_inserted % 2) echo ('');
if ($trigger_underline % 2) echo('');
if ($trigger_floatl % 2) echo ('');
if ($trigger_center % 2) echo ('');
if ($trigger_italic % 2) echo('');
if ($trigger_monospace % 2) echo('');
if ($trigger_bold % 2) echo('');
for ($i = 1; $i<=5; $i ++)
if ($trigger_l[$i] % 2) echo ("");
$trigger_bold = $trigger_center = $trigger_floatl = $trigger_inserted = $trigger_italic =$trigger_keys = 0;
$trigger_l = array(-1, 0, 0, 0, 0, 0);
$trigger_monospace = $trigger_notes = $trigger_strike = $trigger_underline = 0;
return;
}
// convert HTML thingies
if ($thing == "<")
return "<";
else if ($thing == ">")
return ">";
// float box left
else if ($thing == "<<")
{
return (++$trigger_floatl % 2 ? "
\n" : "\n
\n");
}
// float box right
else if ($thing == ">>")
{
return (++$trigger_floatl % 2 ? "\n" : "\n
\n");
}
// clear floated box
else if ($thing == "::c::")
{
return ("
\n");
}
// keyboard
else if ($thing == "#%")
{
return (++$trigger_keys % 2 ? "" : "");
}
// bold
else if ($thing == "**")
{
return (++$trigger_bold % 2 ? "" : "");
}
// italic
else if ($thing == "//")
{
return (++$trigger_italic % 2 ? "" : "");
}
// underlinue
else if ($thing == "__")
{
return (++$trigger_underline % 2 ? "" : "");
}
// monospace
else if ($thing == "##")
{
return (++$trigger_monospace % 2 ? "" : "");
}
// notes
else if ($thing == "''")
{
return (++$trigger_notes % 2 ? "" : "");
}
// strikethrough
else if ($thing == "++" || $thing == "¥¥")
{
return (++$trigger_strike % 2 ? "" : "");
}
// Inserted
else if ($thing == "££")
{
return (++$trigger_inserted % 2 ? "" : "");
}
// centre
else if ($thing == "@@")
{
return (++$trigger_center % 2 ? "\n" : "\n
\n");
}
// urls
else if (preg_match("/^([a-z]+:\/\/\S+?)([^[:alnum:]^\/])?$/", $thing, $matches)) {
$url = $matches[1];
if (preg_match("/^(.*)\.(gif|jpg|png)/si", $url)) {
return "
".$matches[2];
} else
// Mind Mapping Mod
if (preg_match("/^(.*)\.(mm)/si", $url)) {
return $wakka->Action("mindmap ".$url);
} else
return $wakka->Link($url).$matches[2];
}
// header level 5
else if ($thing == "==")
{
$br = 0;
return (++$trigger_l[5] % 2 ? "" : "
\n");
}
// header level 4
else if ($thing == "===")
{
$br = 0;
return (++$trigger_l[4] % 2 ? "" : "
\n");
}
// header level 3
else if ($thing == "====")
{
$br = 0;
return (++$trigger_l[3] % 2 ? "" : "
\n");
}
// header level 2
else if ($thing == "=====")
{
$br = 0;
return (++$trigger_l[2] % 2 ? "" : "
\n");
}
// header level 1
else if ($thing == "======")
{
$br = 0;
return (++$trigger_l[1] % 2 ? "" : "
\n");
}
// forced line breaks
else if ($thing == "---")
{
return "
";
}
// escaped text
else if (preg_match("/^\"\"(.*)\"\"$/s", $thing, $matches))
{
$allowed_double_doublequote_html = $wakka->GetConfigValue("double_doublequote_html");
if ($allowed_double_doublequote_html == 'safe')
{
# return $matches[1];
$filtered_output = $wakka->ReturnSafeHTML($matches[1]);
return $filtered_output;
}
elseif ($allowed_double_doublequote_html == 'raw')
{
return $matches[1];
}
else
{
return htmlspecialchars($matches[1]);
}
}
// code text
else if (preg_match("/^\%\%(.*)\%\%$/s", $thing, $matches))
{
// check if a language has been specified
$code = $matches[1];
$language = "";
if (preg_match("/^\((.+?)\)(.*)$/s", $code, $matches))
{
list(, $language, $code) = $matches;
}
switch ($language)
{
case "php":
$formatter = "php";
break;
case "ini":
$formatter = "ini";
break;
case "email":
$formatter = "email";
break;
default:
$formatter = "code";
}
$output = "\n";
$output .= $wakka->Format(trim($code), $formatter);
$output .= "
\n";
return $output;
}
// forced links
// \S : any character that is not a whitespace character
// \s : any whitespace character
else if (preg_match("/^\[\[(\S*)(\s+(.+))?\]\]$/", $thing, $matches))
{
list (, $url, , $text) = $matches;
if ($url)
{
//if ($url!=($url=(preg_replace("/@@|££||\[\[/","",$url))))$result="";
if (!$text) $text = $url;
//$text=preg_replace("/@@|££|\[\[/","",$text);
return $result.$wakka->Link($url, "", $text);
}
else
{
return "";
}
}
// indented text
elseif (preg_match("/\n([\t,~]+)(-|([0-9,a-z,A-Z,ÄÖÜ,ßäöü]+)\))?(\n|$)/s", $thing, $matches))
{
// new line
$result .= ($br ? "
\n" : "\n");
// we definitely want no line break in this one.
$br = 0;
// find out which indent type we want
$newIndentType = $matches[2];
if (!$newIndentType) { $opener = ""; $closer = "
"; $br = 1; }
elseif ($newIndentType == "-") { $opener = ""; $li = 1; }
else { $opener = "- "; $closer = "
"; $li = 1; }
// get new indent level
$newIndentLevel = strlen($matches[1]);
if ($newIndentLevel > $oldIndentLevel)
{
for ($i = 0; $i < $newIndentLevel - $oldIndentLevel; $i++)
{
$result .= $opener;
array_push($indentClosers, $closer);
}
}
else if ($newIndentLevel < $oldIndentLevel)
{
for ($i = 0; $i < $oldIndentLevel - $newIndentLevel; $i++)
{
$result .= array_pop($indentClosers);
}
}
$oldIndentLevel = $newIndentLevel;
if (isset($li) && !preg_match("/".str_replace(")", "\)", $opener)."$/", $result))
{
$result .= "";
}
return $result;
}
// new lines
else if ($thing == "\n")
{
// if we got here, there was no tab in the next line; this means that we can close all open indents.
$c = count($indentClosers);
for ($i = 0; $i < $c; $i++)
{
$result .= array_pop($indentClosers);
$br = 0;
}
$oldIndentLevel = 0;
$oldIndentLength= 0;
$newIndentSpace=array();
$result .= ($br ? "
\n" : "\n");
$br = 1;
return $result;
}
// Actions
else if (preg_match("/^\{\{(.*?)\}\}$/s", $thing, $matches))
{
if ($matches[1])
return $wakka->Action($matches[1]);
else
return "{{}}";
}
// interwiki links!
else if (preg_match("/^[A-Z,ÄÖÜ][A-Z,a-z,ÄÖÜ,ßäöü]+[:]([A-Z,a-z,0-9,ÄÖÜ,ßäöü]*)$/s", $thing))
{
return $wakka->Link($thing);
}
// wiki links!
else if (preg_match("/^[A-Z,ÄÖÜ]+[a-z,ßäöü]+[A-Z,0-9,ÄÖÜ][A-Z,a-z,0-9,ÄÖÜ,ßäöü]*$/s", $thing))
{
return $wakka->Link($thing);
}
// separators
else if (preg_match("/-{4,}/", $thing, $matches))
{
// TODO: This could probably be improved for situations where someone puts text on the same line as a separator.
// Which is a stupid thing to do anyway! HAW HAW! Ahem.
$br = 0;
return "
\n";
}
// if we reach this point, it must have been an accident.
return $thing;
}
}
$text = str_replace("\r", "", $text);
// replace 4 consecutive spaces at the beginning of a line with tab character
// $text = preg_replace("/\n[ ]{4}/", "\n\t", $text); // moved to edit.php
$text = preg_replace_callback(
"/(\%\%.*?\%\%|".
"\"\".*?\"\"|".
"\[\[[^\[].*?\]\]|".
"-{4,}|---|".
"\b[a-z]+:\/\/\S+|".
"\*\*|\'\'|\#\#|\#\%|@@|::c::|\>\>|\<\<|££|¥¥|\+\+|__|<|>|\/\/|".
"======|=====|====|===|==|".
"\n([\t,~]+)(-|[0-9,a-z,A-Z]+\))?|".
"\{\{.*?\}\}|".
"\b[A-Z,ÄÖÜ][A-Z,a-z,ÄÖÜ,ßäöü]+[:]([A-Z,a-z,0-9,ÄÖÜ,ßäöü]*)\b|".
"\b([A-Z,ÄÖÜ]+[a-z,ßäöü]+[A-Z,0-9,ÄÖÜ][A-Z,a-z,0-9,ÄÖÜ,ßäöü]*)\b|".
"\n)/ms", "wakka2callback", $text);
// horrible ugly table hack v2.0
if( !function_exists('quicktable') )
{
function quicktable($txt)
{
$temp = $txt[0];
$temp = "\n".$temp;
$temp = preg_replace("/^\|\|(.*?)\|\|\
$/m", "$1 |
", $temp);
$temp = str_replace("||", "", $temp);
$temp = str_replace(" ", "", $temp);
$temp = $temp." |
\n
";
return $temp;
}
}
$text = preg_replace_callback("/^\|\|(.*?)\|\|\
\n\
$/sm", "quicktable", $text);
// we're cutting the last
$text = preg_replace("/
$/","", $text);
echo ($text);
wakka2callback('closetags');
?>