From 5b04b9480e19d756a7cbc8456ffaa09b40a61164 Mon Sep 17 00:00:00 2001 From: zottel Date: Fri, 24 Oct 2014 21:17:56 +0200 Subject: make bbcode/html includes work in markdown help pages and vice versa --- mod/help.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'mod/help.php') diff --git a/mod/help.php b/mod/help.php index 81ecd6ba9..4823f1c07 100644 --- a/mod/help.php +++ b/mod/help.php @@ -34,8 +34,6 @@ function help_content(&$a) { $doctype = 'markdown'; - require_once('library/markdown.php'); - $text = ''; if(argc() > 1) { @@ -73,17 +71,22 @@ function help_content(&$a) { )); } - $text = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $text); - if($doctype === 'html') $content = $text; - if($doctype === 'markdown') + if($doctype === 'markdown') { + require_once('library/markdown.php'); + # escape #include tags + $text = preg_replace('/#include/ism', '%%include', $text); $content = Markdown($text); + $content = preg_replace('/%%include/ism', '#include', $content); + } if($doctype === 'bbcode') { require_once('include/bbcode.php'); $content = bbcode($text); } + $content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content); + return replace_macros(get_markup_template("help.tpl"), array( '$content' => $content )); @@ -93,8 +96,17 @@ function help_content(&$a) { function preg_callback_help_include($matches) { - if($matches[1]) - return str_replace($matches[0],load_doc_file($matches[1]),$matches[0]); + if($matches[1]) { + $include = str_replace($matches[0],load_doc_file($matches[1]),$matches[0]); + if(preg_match('/\.bb$/', $matches[1])) { + require_once('include/bbcode.php'); + $include = bbcode($include); + } elseif(preg_match('/\.md$/', $matches[1])) { + require_once('library/markdown.php'); + $include = Markdown($include); + } + return $include; + } } -- cgit v1.2.3 From d67c5a6ffd134602084a6dcb37b316bf768bf715 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sun, 30 Nov 2014 00:34:24 +0000 Subject: Handle included txt files (ie, install doco) as BBCode, otherwise it strips all white space. Was going to use Markdown, but lots of not-markdown gets parsed then, so... --- mod/help.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/help.php') diff --git a/mod/help.php b/mod/help.php index 4823f1c07..a3dafcc9b 100644 --- a/mod/help.php +++ b/mod/help.php @@ -98,7 +98,7 @@ function preg_callback_help_include($matches) { if($matches[1]) { $include = str_replace($matches[0],load_doc_file($matches[1]),$matches[0]); - if(preg_match('/\.bb$/', $matches[1])) { + if(preg_match('/\.bb$/', $matches[1]) || preg_match('/\.txt$/', $matches[1])) { require_once('include/bbcode.php'); $include = bbcode($include); } elseif(preg_match('/\.md$/', $matches[1])) { -- cgit v1.2.3