2 define( 'MARKDOWN_PARSER_CLASS', 'ExtendedMarkdown' );
3 require_once('library/markdown.php');
5 class ExtendedMarkdown extends MarkdownExtra_Parser {
7 function ExtendedMarkdown() {
8 $this->block_gamut += array(
9 "doBlockWarning" => 45,
11 parent::MarkdownExtra_Parser();
14 function doBlockWarning($text) {
15 $text = preg_replace_callback('/
16 ( # Wrap whole match in $1
18 ^[ ]*![ ]? # "!" at the start of a line
19 .+\n # rest of the first line
20 (.+\n)* # subsequent consecutive lines
24 /xm', array(&$this, '_doBlockWarning_callback'), $text);
29 function _doBlockWarning_callback($matches) {
31 # trim one level of quoting - trim whitespace-only lines
32 $bq = preg_replace('/^[ ]*![ ]?|^[ ]+$/m', '', $bq);
33 $bq = $this->runBlockGamut($bq); # recurse
35 $bq = preg_replace('/^/m', " ", $bq);
36 # These leading spaces cause problem with <pre> content,
37 # so we need to fix that:
38 // $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx', array(&$this, '__doBlockWarning_callback2'), $bq);
40 return "\n" . $this->hashBlock("<div class='md_warning'>\n$bq\n</div>") . "\n\n";
43 function _doBlockWarning_callback2($matches) {
45 $pre = preg_replace('/^ /m', '', $pre);
51 if (!function_exists('load_doc_file')) {
53 function load_doc_file($s) {
59 if (file_exists("$d/$lang/$b"))
60 return file_get_contents("$d/$lang/$b");
62 return file_get_contents($s);
68 function help_content(&$a) {
71 nav_set_selected('help');
78 $text = load_doc_file('doc/' . $a->argv[1] . '.md');
79 $a->page['title'] = t('Help:') . ' ' . str_replace('-', ' ', notags($a->argv[1]));
81 $home = load_doc_file('doc/Home.md');
84 $a->page['title'] = t('Help');
86 $a->page['aside'] = Markdown($home);
90 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
91 $tpl = get_markup_template("404.tpl");
92 return replace_macros($tpl, array(
93 '$message' => t('Page not found.')
97 $html = Markdown($text);
98 $html = "<style>.md_warning { padding: 1em; border: #ff0000 solid 2px; background-color: #f9a3a3; color: #ffffff;</style>".$html;