diff options
Diffstat (limited to 'plugins/markdown/markdown.php')
-rw-r--r-- | plugins/markdown/markdown.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 5a702c7b..57fcce32 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -8,6 +8,12 @@ | |||
8 | 8 | ||
9 | require_once 'Parsedown.php'; | 9 | require_once 'Parsedown.php'; |
10 | 10 | ||
11 | /* | ||
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 | */ | ||
15 | define('NO_MD_TAG', '.nomarkdown'); | ||
16 | |||
11 | /** | 17 | /** |
12 | * Parse linklist descriptions. | 18 | * Parse linklist descriptions. |
13 | * | 19 | * |
@@ -18,6 +24,28 @@ require_once 'Parsedown.php'; | |||
18 | function hook_markdown_render_linklist($data) | 24 | function hook_markdown_render_linklist($data) |
19 | { | 25 | { |
20 | foreach ($data['links'] as &$value) { | 26 | foreach ($data['links'] as &$value) { |
27 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { | ||
28 | continue; | ||
29 | } | ||
30 | $value['description'] = process_markdown($value['description']); | ||
31 | } | ||
32 | |||
33 | return $data; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * Parse feed linklist descriptions. | ||
38 | * | ||
39 | * @param array $data linklist data. | ||
40 | * | ||
41 | * @return mixed linklist data parsed in markdown (and converted to HTML). | ||
42 | */ | ||
43 | function hook_markdown_render_feed($data) | ||
44 | { | ||
45 | foreach ($data['links'] as &$value) { | ||
46 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { | ||
47 | continue; | ||
48 | } | ||
21 | $value['description'] = process_markdown($value['description']); | 49 | $value['description'] = process_markdown($value['description']); |
22 | } | 50 | } |
23 | 51 | ||
@@ -36,6 +64,9 @@ function hook_markdown_render_daily($data) | |||
36 | // Manipulate columns data | 64 | // Manipulate columns data |
37 | foreach ($data['cols'] as &$value) { | 65 | foreach ($data['cols'] as &$value) { |
38 | foreach ($value as &$value2) { | 66 | foreach ($value as &$value2) { |
67 | if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) { | ||
68 | continue; | ||
69 | } | ||
39 | $value2['formatedDescription'] = process_markdown($value2['formatedDescription']); | 70 | $value2['formatedDescription'] = process_markdown($value2['formatedDescription']); |
40 | } | 71 | } |
41 | } | 72 | } |
@@ -44,6 +75,18 @@ function hook_markdown_render_daily($data) | |||
44 | } | 75 | } |
45 | 76 | ||
46 | /** | 77 | /** |
78 | * Check if noMarkdown is set in tags. | ||
79 | * | ||
80 | * @param string $tags tag list | ||
81 | * | ||
82 | * @return bool true if markdown should be disabled on this link. | ||
83 | */ | ||
84 | function noMarkdownTag($tags) | ||
85 | { | ||
86 | return strpos($tags, NO_MD_TAG) !== false; | ||
87 | } | ||
88 | |||
89 | /** | ||
47 | * When link list is displayed, include markdown CSS. | 90 | * When link list is displayed, include markdown CSS. |
48 | * | 91 | * |
49 | * @param array $data includes data. | 92 | * @param array $data includes data. |
@@ -75,6 +118,12 @@ function hook_markdown_render_editlink($data) | |||
75 | { | 118 | { |
76 | // Load help HTML into a string | 119 | // Load help HTML into a string |
77 | $data['edit_link_plugin'][] = file_get_contents(PluginManager::$PLUGINS_PATH .'/markdown/help.html'); | 120 | $data['edit_link_plugin'][] = file_get_contents(PluginManager::$PLUGINS_PATH .'/markdown/help.html'); |
121 | |||
122 | // Add no markdown 'meta-tag' in tag list if it was never used, for autocompletion. | ||
123 | if (! in_array(NO_MD_TAG, $data['tags'])) { | ||
124 | $data['tags'][NO_MD_TAG] = 0; | ||
125 | } | ||
126 | |||
78 | return $data; | 127 | return $data; |
79 | } | 128 | } |
80 | 129 | ||