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/Templates/comment_show.php | 2 +- app/Templates/event_comment_create.php | 2 +- app/Templates/event_comment_update.php | 2 +- app/Templates/notification_comment_creation.php | 2 +- app/Templates/notification_comment_update.php | 2 +- .../notification_task_assignee_change.php | 2 +- app/Templates/notification_task_creation.php | 2 +- app/Templates/notification_task_update.php | 2 +- app/Templates/task_show_description.php | 2 +- app/helpers.php | 27 ++++++++-------------- 10 files changed, 18 insertions(+), 27 deletions(-) (limited to 'app') diff --git a/app/Templates/comment_show.php b/app/Templates/comment_show.php index 181a69fa..5069120d 100644 --- a/app/Templates/comment_show.php +++ b/app/Templates/comment_show.php @@ -21,7 +21,7 @@
- +
diff --git a/app/Templates/event_comment_create.php b/app/Templates/event_comment_create.php index 09d45ed0..4af59614 100644 --- a/app/Templates/event_comment_create.php +++ b/app/Templates/event_comment_create.php @@ -3,5 +3,5 @@


-

+

\ No newline at end of file diff --git a/app/Templates/event_comment_update.php b/app/Templates/event_comment_update.php index a42e5dab..fe93b691 100644 --- a/app/Templates/event_comment_update.php +++ b/app/Templates/event_comment_update.php @@ -3,5 +3,5 @@


-

+

\ No newline at end of file diff --git a/app/Templates/notification_comment_creation.php b/app/Templates/notification_comment_creation.php index 44662eca..fac6ea25 100644 --- a/app/Templates/notification_comment_creation.php +++ b/app/Templates/notification_comment_creation.php @@ -2,6 +2,6 @@

- + $task)) ?> \ No newline at end of file diff --git a/app/Templates/notification_comment_update.php b/app/Templates/notification_comment_update.php index 1c279737..92c06ffb 100644 --- a/app/Templates/notification_comment_update.php +++ b/app/Templates/notification_comment_update.php @@ -2,6 +2,6 @@

- + $task)) ?> \ No newline at end of file diff --git a/app/Templates/notification_task_assignee_change.php b/app/Templates/notification_task_assignee_change.php index 9c2bee56..65194f1e 100644 --- a/app/Templates/notification_task_assignee_change.php +++ b/app/Templates/notification_task_assignee_change.php @@ -14,7 +14,7 @@

- + $task)) ?> \ No newline at end of file diff --git a/app/Templates/notification_task_creation.php b/app/Templates/notification_task_creation.php index 0ec5bfc6..43b3b291 100644 --- a/app/Templates/notification_task_creation.php +++ b/app/Templates/notification_task_creation.php @@ -37,7 +37,7 @@

- + $task)) ?> \ No newline at end of file diff --git a/app/Templates/notification_task_update.php b/app/Templates/notification_task_update.php index 21c1c3aa..9fd61b57 100644 --- a/app/Templates/notification_task_update.php +++ b/app/Templates/notification_task_update.php @@ -37,7 +37,7 @@

- + $task)) ?> \ No newline at end of file diff --git a/app/Templates/task_show_description.php b/app/Templates/task_show_description.php index 2d90137f..67a38444 100644 --- a/app/Templates/task_show_description.php +++ b/app/Templates/task_show_description.php @@ -5,7 +5,7 @@
- +
\ No newline at end of file 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