mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 2272462503ce143b6f4f8006e8eec94da7a6a7c2
parent 96e4bbb70c6349e25f9ce47ebe176f8cbd29052e
Author: markseu <mark2011@mayberg.se>
Date:   Sun,  6 Mar 2016 20:22:13 +0100

System update (better Markdown)

Diffstat:
Msystem/plugins/markdown.php | 25+++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/system/plugins/markdown.php b/system/plugins/markdown.php @@ -5,7 +5,7 @@ // Markdown plugin class YellowMarkdown { - const Version = "0.6.2"; + const Version = "0.6.3"; var $yellow; //access to API // Handle initialisation @@ -62,13 +62,23 @@ class YellowMarkdownParser extends MarkdownExtraParser { $text = preg_replace_callback("/<(\w+:[^\'\">\s]+)>/", array(&$this, "_doAutoLinks_url_callback"), $text); $text = preg_replace_callback("/<([\w\-\.]+@[\w\-\.]+)>/", array(&$this, "_doAutoLinks_email_callback"), $text); - $text = preg_replace_callback("/\[(\w+)(.*?)\]/", array(&$this, "_doAutoLinks_shortcut_callback"), $text); $text = preg_replace_callback("/\[\-\-(.*?)\-\-\]/", array(&$this, "_doAutoLinks_comment_callback"), $text); + $text = preg_replace_callback("/\[(\w+)(.*?)\]/", array(&$this, "_doAutoLinks_shortcut_callback"), $text); + $text = preg_replace_callback("/\:([\w\+\-\_]+)\:/", array(&$this, "_doAutoLinks_shortcode_callback"), $text); $text = preg_replace_callback("/((http|https|ftp):\/\/\S+[^\'\"\,\.\;\:\s]+)/", array(&$this, "_doAutoLinks_url_callback"), $text); $text = preg_replace_callback("/([\w\-\.]+@[\w\-\.]+\.[\w]{2,4})/", array(&$this, "_doAutoLinks_email_callback"), $text); return $text; } + // Handle comments + function _doAutoLinks_comment_callback($matches) + { + $text = $matches[1]; + $output = "<!--".htmlspecialchars($text, ENT_NOQUOTES)."-->"; + if($text[0] == '-') $output = ""; + return $this->hashBlock($output); + } + // Handle shortcuts function _doAutoLinks_shortcut_callback($matches) { @@ -77,13 +87,12 @@ class YellowMarkdownParser extends MarkdownExtraParser return substr($output, 0, 4)=="<div" ? $this->hashBlock(trim($output)) : $this->hashPart(trim($output)); } - // Handle comments - function _doAutoLinks_comment_callback($matches) + // Handle shortcodes + function _doAutoLinks_shortcode_callback($matches) { - $text = $matches[1]; - $output = "<!--".htmlspecialchars($text, ENT_NOQUOTES)."-->"; - if($text[0] == '-') $output = ""; - return $this->hashBlock($output); + $output = $this->page->parseContentBlock("", trim($matches[1]), true); + if(is_null($output)) $output = htmlspecialchars($matches[0], ENT_NOQUOTES); + return $this->hashPart($output); } // Handle fenced code blocks