diff --git a/src/feed.php b/src/feed.php index 8fd73ab..b74f298 100644 --- a/src/feed.php +++ b/src/feed.php @@ -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("
", htmlarray($a)). "

". $r['note']; $r['_title'] = "#". (int)$r['id']. ": ". $r['title']; $r['_d'] = gmdate('r', $r[$field]); diff --git a/src/includes/markup.php b/src/includes/markup.php index 255f5c1..886f9f7 100644 --- a/src/includes/markup.php +++ b/src/includes/markup.php @@ -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); diff --git a/src/includes/parsedown/MTTParsedown.php b/src/includes/parsedown/MTTParsedown.php index ae7901a..639f8e9 100644 --- a/src/includes/parsedown/MTTParsedown.php +++ b/src/includes/parsedown/MTTParsedown.php @@ -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, ), );