Replace Markdown parser by Parsedown
This commit is contained in:
parent
23753bde1c
commit
3fa549352c
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the Markdown parser.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
require_once dirname(__FILE__) . '/Markdown.php';
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the MarkdownExtra parser.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
require_once dirname(__FILE__) . '/Markdown.php';
|
||||
require_once dirname(__FILE__) . '/MarkdownExtra.php';
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
#
|
||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown Extra
|
||||
# Copyright (c) 2004-2014 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
namespace Michelf;
|
||||
|
||||
|
||||
# Just force Michelf/Markdown.php to load. This is needed to load
|
||||
# the temporary implementation class. See below for details.
|
||||
\Michelf\Markdown::MARKDOWNLIB_VERSION;
|
||||
|
||||
#
|
||||
# Markdown Extra Parser Class
|
||||
#
|
||||
# Note: Currently the implementation resides in the temporary class
|
||||
# \Michelf\MarkdownExtra_TmpImpl (in the same file as \Michelf\Markdown).
|
||||
# This makes it easier to propagate the changes between the three different
|
||||
# packaging styles of PHP Markdown. Once this issue is resolved, the
|
||||
# _MarkdownExtra_TmpImpl will disappear and this one will contain the code.
|
||||
#
|
||||
|
||||
class MarkdownExtra extends \Michelf\_MarkdownExtra_TmpImpl {
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
# Temporarily, the implemenation is in the _MarkdownExtra_TmpImpl class.
|
||||
# See note above.
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the MarkdownInterface interface.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
#
|
||||
# Markdown - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown
|
||||
# Copyright (c) 2004-2014 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
namespace Michelf;
|
||||
|
||||
|
||||
#
|
||||
# Markdown Parser Interface
|
||||
#
|
||||
|
||||
interface MarkdownInterface {
|
||||
|
||||
#
|
||||
# Initialize the parser and return the result of its transform method.
|
||||
# This will work fine for derived classes too.
|
||||
#
|
||||
public static function defaultTransform($text);
|
||||
|
||||
#
|
||||
# Main function. Performs some preprocessing on the input text
|
||||
# and pass it through the document gamut.
|
||||
#
|
||||
public function transform($text);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Emanuil Rusev, erusev.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue