diff options
-rw-r--r-- | plugins/markdown/markdown.php | 19 | ||||
-rw-r--r-- | tests/plugins/PluginMarkdownTest.php | 6 |
2 files changed, 20 insertions, 5 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 57fcce32..5f56ecc2 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -10,9 +10,8 @@ require_once 'Parsedown.php'; | |||
10 | 10 | ||
11 | /* | 11 | /* |
12 | * If this tag is used on a shaare, the description won't be processed by Parsedown. | 12 | * If this tag is used on a shaare, the description won't be processed by Parsedown. |
13 | * Using a private tag so it won't appear for visitors. | ||
14 | */ | 13 | */ |
15 | define('NO_MD_TAG', '.nomarkdown'); | 14 | define('NO_MD_TAG', 'nomarkdown'); |
16 | 15 | ||
17 | /** | 16 | /** |
18 | * Parse linklist descriptions. | 17 | * Parse linklist descriptions. |
@@ -25,11 +24,11 @@ function hook_markdown_render_linklist($data) | |||
25 | { | 24 | { |
26 | foreach ($data['links'] as &$value) { | 25 | foreach ($data['links'] as &$value) { |
27 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { | 26 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { |
27 | $value['taglist'] = stripNoMarkdownTag($value['taglist']); | ||
28 | continue; | 28 | continue; |
29 | } | 29 | } |
30 | $value['description'] = process_markdown($value['description']); | 30 | $value['description'] = process_markdown($value['description']); |
31 | } | 31 | } |
32 | |||
33 | return $data; | 32 | return $data; |
34 | } | 33 | } |
35 | 34 | ||
@@ -44,6 +43,7 @@ function hook_markdown_render_feed($data) | |||
44 | { | 43 | { |
45 | foreach ($data['links'] as &$value) { | 44 | foreach ($data['links'] as &$value) { |
46 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { | 45 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { |
46 | $value['tags'] = stripNoMarkdownTag($value['tags']); | ||
47 | continue; | 47 | continue; |
48 | } | 48 | } |
49 | $value['description'] = process_markdown($value['description']); | 49 | $value['description'] = process_markdown($value['description']); |
@@ -87,6 +87,19 @@ function noMarkdownTag($tags) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Remove the no-markdown meta tag so it won't be displayed. | ||
91 | * | ||
92 | * @param string $tags Tag list. | ||
93 | * | ||
94 | * @return string tag list without no markdown tag. | ||
95 | */ | ||
96 | function stripNoMarkdownTag($tags) | ||
97 | { | ||
98 | unset($tags[array_search(NO_MD_TAG, $tags)]); | ||
99 | return array_values($tags); | ||
100 | } | ||
101 | |||
102 | /** | ||
90 | * When link list is displayed, include markdown CSS. | 103 | * When link list is displayed, include markdown CSS. |
91 | * | 104 | * |
92 | * @param array $data includes data. | 105 | * @param array $data includes data. |
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php index fa7e1d52..3593a556 100644 --- a/tests/plugins/PluginMarkdownTest.php +++ b/tests/plugins/PluginMarkdownTest.php | |||
@@ -125,7 +125,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
125 | $data = array( | 125 | $data = array( |
126 | 'links' => array(array( | 126 | 'links' => array(array( |
127 | 'description' => $str, | 127 | 'description' => $str, |
128 | 'tags' => NO_MD_TAG | 128 | 'tags' => NO_MD_TAG, |
129 | 'taglist' => array(NO_MD_TAG), | ||
129 | )) | 130 | )) |
130 | ); | 131 | ); |
131 | 132 | ||
@@ -140,7 +141,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
140 | // nth link | 141 | // nth link |
141 | 0 => array( | 142 | 0 => array( |
142 | 'formatedDescription' => $str, | 143 | 'formatedDescription' => $str, |
143 | 'tags' => NO_MD_TAG | 144 | 'tags' => NO_MD_TAG, |
145 | 'taglist' => array(), | ||
144 | ), | 146 | ), |
145 | ), | 147 | ), |
146 | ), | 148 | ), |