blob: 3dd986178bcef00da6a0f7b26423f5c77329542a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace Core;
use Parsedown;
/**
* Specific Markdown rules for Kanboard
*
* @package core
* @author norcnorc
* @author Frederic Guillot
*/
class Markdown extends Parsedown
{
private $link;
private $helper;
public function __construct($link, Helper $helper)
{
$this->link = $link;
$this->helper = $helper;
$this->InlineTypes['#'][] = 'TaskLink';
$this->inlineMarkerList .= '#';
}
protected function inlineTaskLink($Excerpt)
{
// Replace task #123 by a link to the task
if (! empty($this->link) && preg_match('!#(\d+)!i', $Excerpt['text'], $matches)) {
$url = $this->helper->u($this->link['controller'],
$this->link['action'],
$this->link['params'] + array('task_id' => $matches[1]));
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'a',
'text' => $matches[0],
'attributes' => array('href' => $url)));
}
}
}
|