blob: f08c486a98f65b856810d86bd28a1d2f7f639e1a (
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
44
45
46
|
<?php
namespace Kanboard\Core;
use Parsedown;
use Kanboard\Helper\Url;
/**
* Specific Markdown rules for Kanboard
*
* @package core
* @author norcnorc
* @author Frederic Guillot
*/
class Markdown extends Parsedown
{
private $link;
private $helper;
public function __construct($link, Url $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->href(
$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)));
}
}
}
|