*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
include_once(DOKU_INC.'inc/common.php');
include_once(DOKU_INC.'inc/html.php');
include_once(DOKU_INC.'inc/format.php');
require_once(DOKU_INC.'lang/en/lang.php');
require_once(DOKU_INC.'lang/'.$conf['lang'].'/lang.php');
/**
* The main parser function.
*
* Accepts raw data and returns valid xhtml
*
* @author Andreas Gohr \n* ";
$pc = mkToken();
$table[$pc] = "(.*?)
#se","preformat('\\3','code','\\2')");
firstpass($table,$text,"#(.*?)
#","",$line);
$line = preg_replace("#
"; //open new paragraph //remember for autoTOC if($hl['level'] <= $conf['maxtoclevel']){ $content[] = array('id' => $hash, 'name' => $hl['name'], 'level' => $hl['level']); } //add link for section edit for HLs 1, and 3 if( ($hl['level'] <= $conf['maxseclevel']) && ($hl['line'] - $last > 1)){ $secedit = ''; $headline = $secedit.$headline; $last = $hl['line']; } //put headline into firstpasstable $table[$hl['token']] = $headline; } //add link for editing the last section if($last){ $secedit = ''; $token = mktoken(); $text .= $token; $table[$token] = $secedit; } //close last div if ($cnt){ $token = mktoken(); $text .= $token; $table[$token] = '
\1
',$text); //code
$text = preg_replace('#<del>(.*?)</del>#is','",$text); //hr
//sub and superscript
$text = preg_replace('#<sub>(.*?)</sub>#is','\1',$text);
$text = preg_replace('#<sup>(.*?)</sup>#is','\1',$text);
//do quoting
$text = preg_replace("/\n((>)[^\n]*?\n)+/se","'\n'.quoteformat('\\0').'\n'",$text);
// Typography
if($conf['typography']){
$text = preg_replace('/([^-])--([^-])/s','\1–\2',$text); //endash
$text = preg_replace('/([^-])---([^-])/s','\1—\2',$text); //emdash
$text = preg_replace('/"([^\"]+?)"/s','“\1”',$text); //curly quotes
$text = preg_replace('/(\s)\'(\S)/m','\1‘\2',$text); //single open quote
$text = preg_replace('/(\S)\'/','\1’',$text); //single closing quote or apostroph
$text = preg_replace('/\.\.\./','\1…\2',$text); //ellipse
$text = preg_replace('/(\d+)x(\d+)/i','\1×\2',$text); //640x480
$text = preg_replace('/>>/i','»',$text); // >>
$text = preg_replace('/<</i','«',$text); // <<
$text = preg_replace('/<->/i','↔',$text); // <->
$text = preg_replace('/<-/i','←',$text); // <-
$text = preg_replace('/->/i','→',$text); // ->
$text = preg_replace('/<=>/i','⇔',$text); // <=>
$text = preg_replace('/<=/i','⇐',$text); // <=
$text = preg_replace('/=>/i','⇒',$text); // =>
$text = preg_replace('/\(c\)/i','©',$text); // copyrigtht
$text = preg_replace('/\(r\)/i','®',$text); // registered
$text = preg_replace('/\(tm\)/i','™',$text); // trademark
}
//forced linebreaks
$text = preg_replace('#\\\\\\\\(\s)#',"
\\1",$text);
// lists (blocks leftover after blockformat)
$text = preg_replace("/(\n( {2,}|\t)[\*\-][^\n]+)(\n( {2,}|\t)[^\n]*)*/se","\"\\n\".listformat('\\0')",$text);
// tables
$text = preg_replace("/\n(([\|\^][^\n]*?)+[\|\^] *\n)+/se","\"\\n\".tableformat('\\0')",$text);
// footnotes
$text = footnotes($text);
// run custom text replacements
$text = customs($text);
return $text;
}
/**
* Footnote formating
*
* @author Andreas Gohr ';
$sm[0] = preg_quote($sm[0],'/');
firstpass($table,$text,'/(\W)'.$sm[0].'(\W)/s',$sm[1],"\\1","\\2");
}
}
/**
* Add acronym tags to known acronyms
*
* @author Andreas Gohr
"; }elseif($cnt < $lvl){ $ret .= "\n
"; for ($i=0; $i< $lvl - $cnt; $i++){ $ret .= "\n"; }elseif(empty($line)){ $ret .= "
\n"; } //keep rest of line but trim left whitespaces $ret .= ltrim($line)."\n"; //remember level $lvl = $cnt; } //close remaining divs $ret .= "
\n"; for ($i=0; $i< $lvl; $i++){ $ret .= "\n"; } $ret .= "\n";
return "$ret";
}
/**
* format inline tables
*
* @author Andreas Gohr
$data | \n"; // set css class for alignment } else { $ret .= "$data | \n"; // set css class for alignment } } $ret .= "
---|
";
return $ret;
}
/**
* format lists
*
* @author Andreas Gohr
";
}
/**
* Handle preformatted blocks
*
* Uses GeSHi for syntax highlighting
*
* @author Andreas Gohr
".$text."\n
"; break; case 'code': if(empty($option)){ $text = htmlspecialchars($text); $text = '
'.$text.''; }else{ //strip leading blank line $text = preg_replace('/^\s*?\n/','',$text); //use geshi for highlighting require_once("inc/geshi.php"); $geshi = new GeSHi($text, strtolower($option), "inc/geshi"); $geshi->set_encoding($lang['encoding']); $geshi->enable_classes(); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_overall_class('code'); $geshi->set_link_target($conf['target']['extern']); $text = $geshi->parse_code(); } $text = "\n".$text."\n
"; break; case 'block': $text = substr($text,1); //remove 1st newline $lines = split("\n",$text); //break into lines $text = ''; foreach($lines as $line){ $text .= substr($line,2)."\n"; //remove indents } $text = htmlspecialchars($text); $text = "
\n".$text."\n
";
break;
}
return $text;
}
/**
* Format embedded media (images)
*
* @author Andreas Gohr