mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
support markdown in rss feed
This commit is contained in:
parent
341eeac12a
commit
f5fd1f74bb
3 changed files with 24 additions and 11 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
$dontStartSession = 1;
|
||||
require_once('./init.php');
|
||||
require_once(MTTINC. 'markup.php');
|
||||
|
||||
$lang = Lang::instance();
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ function fillData(&$data, $listId, $field, $sqlWhere )
|
|||
$a[] = $lang->get('taskdate_completed'). ": ". timestampToDatetime($r['d_completed']);
|
||||
}
|
||||
$r['title'] = htmlspecialchars( $r['title'] );
|
||||
$r['note'] = mttMarkup_v1($r['note']);
|
||||
$r['note'] = noteMarkup($r['note'], true);
|
||||
$r['_descr'] = implode("<br/>", htmlarray($a)). "<br/><br/>". $r['note'];
|
||||
$r['_title'] = "#". (int)$r['id']. ": ". $r['title'];
|
||||
$r['_d'] = gmdate('r', $r[$field]);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ require_once(MTTINC. 'parsedown/Parsedown.php');
|
|||
require_once(MTTINC. 'parsedown/MTTParsedown.php');
|
||||
|
||||
|
||||
function noteMarkup($note)
|
||||
function noteMarkup($note, $toExternal = false)
|
||||
{
|
||||
if ($note === null) {
|
||||
$note = '';
|
||||
|
|
@ -18,13 +18,14 @@ function noteMarkup($note)
|
|||
if (Config::get('markup') == 'v1') {
|
||||
return mttMarkup_v1($note);
|
||||
}
|
||||
return markdownToHtml($note);
|
||||
return markdownToHtml($note, $toExternal);
|
||||
}
|
||||
|
||||
// Markdown converter (Parsedown)
|
||||
function markdownToHtml($s)
|
||||
function markdownToHtml($s, $toExternal = false)
|
||||
{
|
||||
$parser = MTTParsedown::instance();
|
||||
$parser->setToExternal($toExternal);
|
||||
$parser->setSafeMode(true);
|
||||
//$parser->setBreaksEnabled(true);
|
||||
return $parser->text($s);
|
||||
|
|
|
|||
|
|
@ -9,17 +9,33 @@
|
|||
class MTTParsedown extends Parsedown
|
||||
{
|
||||
|
||||
protected $toExternal;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->InlineTypes['#'][]= 'TaskId';
|
||||
$this->toExternal = false;
|
||||
|
||||
$this->InlineTypes['#'][]= 'TaskId';
|
||||
$this->inlineMarkerList .= '#';
|
||||
}
|
||||
|
||||
public function setToExternal(bool $v)
|
||||
{
|
||||
$this->toExternal = $v;
|
||||
}
|
||||
|
||||
protected function inlineTaskId($excerpt)
|
||||
{
|
||||
if (preg_match('/^#(\d+)/', $excerpt['text'], $matches))
|
||||
{
|
||||
$attrs = array(
|
||||
'href' => get_mttinfo('url'). '?task='. $matches[1],
|
||||
'target' => '_blank',
|
||||
);
|
||||
if (!$this->toExternal) {
|
||||
$attrs['class'] = 'mtt-link-to-task';
|
||||
$attrs['target-id'] = $matches[1];
|
||||
}
|
||||
return array(
|
||||
|
||||
// How many characters to advance the Parsedown's
|
||||
|
|
@ -28,12 +44,7 @@ class MTTParsedown extends Parsedown
|
|||
'element' => array(
|
||||
'name' => 'a',
|
||||
'text' => '#'. $matches[1],
|
||||
'attributes' => array(
|
||||
'href' => get_mttinfo('url'). '?task='. $matches[1],
|
||||
'target' => '_blank',
|
||||
'class' => 'mtt-link-to-task',
|
||||
'target-id' => $matches[1],
|
||||
),
|
||||
'attributes' => $attrs,
|
||||
),
|
||||
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue