diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Templates/comment_show.php | 2 | ||||
-rw-r--r-- | app/Templates/event_comment_create.php | 2 | ||||
-rw-r--r-- | app/Templates/event_comment_update.php | 2 | ||||
-rw-r--r-- | app/Templates/notification_comment_creation.php | 2 | ||||
-rw-r--r-- | app/Templates/notification_comment_update.php | 2 | ||||
-rw-r--r-- | app/Templates/notification_task_assignee_change.php | 2 | ||||
-rw-r--r-- | app/Templates/notification_task_creation.php | 2 | ||||
-rw-r--r-- | app/Templates/notification_task_update.php | 2 | ||||
-rw-r--r-- | app/Templates/task_show_description.php | 2 | ||||
-rw-r--r-- | app/helpers.php | 27 |
10 files changed, 18 insertions, 27 deletions
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 @@ <?php endif ?> <div class="markdown"> - <?= Helper\parse($comment['comment']) ?> + <?= Helper\markdown($comment['comment']) ?> </div> </div> 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 @@ </p> <p class="activity-description"> <em><?= Helper\escape($task_title) ?></em><br/> - <div class="markdown"><?= Helper\parse($comment) ?></div> + <div class="markdown"><?= Helper\markdown($comment) ?></div> </p>
\ 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 @@ </p> <p class="activity-description"> <em><?= Helper\escape($task_title) ?></em><br/> - <div class="markdown"><?= Helper\parse($comment) ?></div> + <div class="markdown"><?= Helper\markdown($comment) ?></div> </p>
\ 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 @@ <h3><?= t('New comment posted by %s', $comment['name'] ?: $comment['username']) ?></h3> -<?= Helper\parse($comment['comment']) ?> +<?= Helper\markdown($comment['comment']) ?> <?= Helper\template('notification_footer', array('task' => $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 @@ <h3><?= t('Comment updated') ?></h3> -<?= Helper\parse($comment['comment']) ?> +<?= Helper\markdown($comment['comment']) ?> <?= Helper\template('notification_footer', array('task' => $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 @@ <?php if (! empty($task['description'])): ?> <h2><?= t('Description') ?></h2> - <?= Helper\parse($task['description']) ?: t('There is no description.') ?> + <?= Helper\markdown($task['description']) ?: t('There is no description.') ?> <?php endif ?> <?= Helper\template('notification_footer', array('task' => $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 @@ <?php if (! empty($task['description'])): ?> <h2><?= t('Description') ?></h2> - <?= Helper\parse($task['description']) ?> + <?= Helper\markdown($task['description']) ?> <?php endif ?> <?= Helper\template('notification_footer', array('task' => $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 @@ <?php if (! empty($task['description'])): ?> <h2><?= t('Description') ?></h2> - <?= Helper\parse($task['description']) ?: t('There is no description.') ?> + <?= Helper\markdown($task['description']) ?: t('There is no description.') ?> <?php endif ?> <?= Helper\template('notification_footer', array('task' => $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 @@ </div> <article class="markdown task-show-description"> - <?= Helper\parse($task['description']) ?: t('There is no description.') ?> + <?= Helper\markdown($task['description']) ?: t('There is no description.') ?> </article> </div> <?php endif ?>
\ 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 @@ -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; } /** |