From 3fa549352ca13d020a8cffaaad0db81b7c66c5b3 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 27 Sep 2014 21:12:12 -0400 Subject: Replace Markdown parser by Parsedown --- app/helpers.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'app/helpers.php') diff --git a/app/helpers.php b/app/helpers.php index 0638e5a4..c56636e9 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -10,7 +10,7 @@ namespace Helper; use Core\Security; use Core\Template; use Core\Tool; -use Michelf\MarkdownExtra; +use Parsedown\Parsedown; /** * Append a CSRF token to a query string @@ -100,19 +100,6 @@ function get_user_id() return $_SESSION['user']['id']; } -/** - * Transform a Markdown text to HTML and add some post-processing - * - * @param string $text Markdown content - * @return string - */ -function parse($text) -{ - $text = markdown($text); - $text = preg_replace('!#(\d+)!i', '$0', $text); - return $text; -} - /** * Markdown transformation * @@ -121,10 +108,14 @@ function parse($text) */ function markdown($text) { - $parser = new MarkdownExtra; - $parser->no_markup = true; - $parser->no_entities = true; - return $parser->transform($text); + $html = Parsedown::instance() + ->setMarkupEscaped(true) # escapes markup (HTML) + ->text($text); + + // Replace task #123 by a link to the task + $html = preg_replace('!#(\d+)!i', '$0', $html); + + return $html; } /** -- cgit v1.2.3