summaryrefslogtreecommitdiff
path: root/app/helpers.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-27 21:12:12 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-09-27 21:12:12 -0400
commit3fa549352ca13d020a8cffaaad0db81b7c66c5b3 (patch)
tree112a940163db29375e69f0590646d999034f0ccf /app/helpers.php
parent23753bde1c1f980f481fec247ced2f4cecc227f3 (diff)
Replace Markdown parser by Parsedown
Diffstat (limited to 'app/helpers.php')
-rw-r--r--app/helpers.php27
1 files changed, 9 insertions, 18 deletions
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
@@ -101,19 +101,6 @@ function get_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', '<a href="?controller=task&action=show&task_id=$1">$0</a>', $text);
- return $text;
-}
-
-/**
* Markdown transformation
*
* @param string $text Markdown content
@@ -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', '<a href="?controller=task&action=show&task_id=$1">$0</a>', $html);
+
+ return $html;
}
/**