Replace Markdown parser by Parsedown
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<div class="markdown">
|
<div class="markdown">
|
||||||
<?= Helper\parse($comment['comment']) ?>
|
<?= Helper\markdown($comment['comment']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em><br/>
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
<div class="markdown"><?= Helper\parse($comment) ?></div>
|
<div class="markdown"><?= Helper\markdown($comment) ?></div>
|
||||||
</p>
|
</p>
|
||||||
@@ -3,5 +3,5 @@
|
|||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em><br/>
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
<div class="markdown"><?= Helper\parse($comment) ?></div>
|
<div class="markdown"><?= Helper\markdown($comment) ?></div>
|
||||||
</p>
|
</p>
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
<h3><?= t('New comment posted by %s', $comment['name'] ?: $comment['username']) ?></h3>
|
<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)) ?>
|
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
<h3><?= t('Comment updated') ?></h3>
|
<h3><?= t('Comment updated') ?></h3>
|
||||||
|
|
||||||
<?= Helper\parse($comment['comment']) ?>
|
<?= Helper\markdown($comment['comment']) ?>
|
||||||
|
|
||||||
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<?php if (! empty($task['description'])): ?>
|
<?php if (! empty($task['description'])): ?>
|
||||||
<h2><?= t('Description') ?></h2>
|
<h2><?= t('Description') ?></h2>
|
||||||
<?= Helper\parse($task['description']) ?: t('There is no description.') ?>
|
<?= Helper\markdown($task['description']) ?: t('There is no description.') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<?php if (! empty($task['description'])): ?>
|
<?php if (! empty($task['description'])): ?>
|
||||||
<h2><?= t('Description') ?></h2>
|
<h2><?= t('Description') ?></h2>
|
||||||
<?= Helper\parse($task['description']) ?>
|
<?= Helper\markdown($task['description']) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<?php if (! empty($task['description'])): ?>
|
<?php if (! empty($task['description'])): ?>
|
||||||
<h2><?= t('Description') ?></h2>
|
<h2><?= t('Description') ?></h2>
|
||||||
<?= Helper\parse($task['description']) ?: t('There is no description.') ?>
|
<?= Helper\markdown($task['description']) ?: t('There is no description.') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
<?= Helper\template('notification_footer', array('task' => $task)) ?>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<article class="markdown task-show-description">
|
<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>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@@ -10,7 +10,7 @@ namespace Helper;
|
|||||||
use Core\Security;
|
use Core\Security;
|
||||||
use Core\Template;
|
use Core\Template;
|
||||||
use Core\Tool;
|
use Core\Tool;
|
||||||
use Michelf\MarkdownExtra;
|
use Parsedown\Parsedown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a CSRF token to a query string
|
* Append a CSRF token to a query string
|
||||||
@@ -100,19 +100,6 @@ function get_user_id()
|
|||||||
return $_SESSION['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
|
* Markdown transformation
|
||||||
*
|
*
|
||||||
@@ -121,10 +108,14 @@ function parse($text)
|
|||||||
*/
|
*/
|
||||||
function markdown($text)
|
function markdown($text)
|
||||||
{
|
{
|
||||||
$parser = new MarkdownExtra;
|
$html = Parsedown::instance()
|
||||||
$parser->no_markup = true;
|
->setMarkupEscaped(true) # escapes markup (HTML)
|
||||||
$parser->no_entities = true;
|
->text($text);
|
||||||
return $parser->transform($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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
10
vendor/Michelf/Markdown.inc.php
vendored
10
vendor/Michelf/Markdown.inc.php
vendored
@@ -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';
|
|
||||||
3144
vendor/Michelf/Markdown.php
vendored
3144
vendor/Michelf/Markdown.php
vendored
File diff suppressed because it is too large
Load Diff
11
vendor/Michelf/MarkdownExtra.inc.php
vendored
11
vendor/Michelf/MarkdownExtra.inc.php
vendored
@@ -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';
|
|
||||||
38
vendor/Michelf/MarkdownExtra.php
vendored
38
vendor/Michelf/MarkdownExtra.php
vendored
@@ -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.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
9
vendor/Michelf/MarkdownInterface.inc.php
vendored
9
vendor/Michelf/MarkdownInterface.inc.php
vendored
@@ -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';
|
|
||||||
34
vendor/Michelf/MarkdownInterface.php
vendored
34
vendor/Michelf/MarkdownInterface.php
vendored
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
20
vendor/Parsedown/LICENSE.txt
vendored
Normal file
20
vendor/Parsedown/LICENSE.txt
vendored
Normal file
@@ -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.
|
||||||
1423
vendor/Parsedown/Parsedown.php
vendored
Normal file
1423
vendor/Parsedown/Parsedown.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user