Replace Markdown parser by Parsedown
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<?php endif ?>
|
||||
|
||||
<div class="markdown">
|
||||
<?= Helper\parse($comment['comment']) ?>
|
||||
<?= Helper\markdown($comment['comment']) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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)) ?>
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
<h3><?= t('Comment updated') ?></h3>
|
||||
|
||||
<?= Helper\parse($comment['comment']) ?>
|
||||
<?= Helper\markdown($comment['comment']) ?>
|
||||
|
||||
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||
@@ -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)) ?>
|
||||
@@ -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)) ?>
|
||||
@@ -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)) ?>
|
||||
@@ -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 ?>
|
||||
@@ -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', '<a href="?controller=task&action=show&task_id=$1">$0</a>', $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', '<a href="?controller=task&action=show&task_id=$1">$0</a>', $html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user