diff options
Diffstat (limited to 'plugins/markdown/markdown.php')
-rw-r--r-- | plugins/markdown/markdown.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 1531549d..821bb125 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -6,6 +6,8 @@ | |||
6 | * Shaare's descriptions are parsed with Markdown. | 6 | * Shaare's descriptions are parsed with Markdown. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | use Shaarli\Config\ConfigManager; | ||
10 | |||
9 | /* | 11 | /* |
10 | * 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. |
11 | */ | 13 | */ |
@@ -50,6 +52,7 @@ function hook_markdown_render_feed($data, $conf) | |||
50 | $value = stripNoMarkdownTag($value); | 52 | $value = stripNoMarkdownTag($value); |
51 | continue; | 53 | continue; |
52 | } | 54 | } |
55 | $value['description'] = reverse_feed_permalink($value['description']); | ||
53 | $value['description'] = process_markdown( | 56 | $value['description'] = process_markdown( |
54 | $value['description'], | 57 | $value['description'], |
55 | $conf->get('security.markdown_escape', true), | 58 | $conf->get('security.markdown_escape', true), |
@@ -70,19 +73,18 @@ function hook_markdown_render_feed($data, $conf) | |||
70 | */ | 73 | */ |
71 | function hook_markdown_render_daily($data, $conf) | 74 | function hook_markdown_render_daily($data, $conf) |
72 | { | 75 | { |
76 | //var_dump($data);die; | ||
73 | // Manipulate columns data | 77 | // Manipulate columns data |
74 | foreach ($data['cols'] as &$value) { | 78 | foreach ($data['linksToDisplay'] as &$value) { |
75 | foreach ($value as &$value2) { | 79 | if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { |
76 | if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) { | 80 | $value = stripNoMarkdownTag($value); |
77 | $value2 = stripNoMarkdownTag($value2); | 81 | continue; |
78 | continue; | ||
79 | } | ||
80 | $value2['formatedDescription'] = process_markdown( | ||
81 | $value2['formatedDescription'], | ||
82 | $conf->get('security.markdown_escape', true), | ||
83 | $conf->get('security.allowed_protocols') | ||
84 | ); | ||
85 | } | 82 | } |
83 | $value['formatedDescription'] = process_markdown( | ||
84 | $value['formatedDescription'], | ||
85 | $conf->get('security.markdown_escape', true), | ||
86 | $conf->get('security.allowed_protocols') | ||
87 | ); | ||
86 | } | 88 | } |
87 | 89 | ||
88 | return $data; | 90 | return $data; |
@@ -136,7 +138,7 @@ function hook_markdown_render_includes($data) | |||
136 | || $data['_PAGE_'] == Router::$PAGE_DAILY | 138 | || $data['_PAGE_'] == Router::$PAGE_DAILY |
137 | || $data['_PAGE_'] == Router::$PAGE_EDITLINK | 139 | || $data['_PAGE_'] == Router::$PAGE_EDITLINK |
138 | ) { | 140 | ) { |
139 | 141 | ||
140 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; | 142 | $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; |
141 | } | 143 | } |
142 | 144 | ||
@@ -245,6 +247,11 @@ function reverse_space2nbsp($description) | |||
245 | return preg_replace('/(^| ) /m', '$1 ', $description); | 247 | return preg_replace('/(^| ) /m', '$1 ', $description); |
246 | } | 248 | } |
247 | 249 | ||
250 | function reverse_feed_permalink($description) | ||
251 | { | ||
252 | return preg_replace('@— <a href="([^"]+)" title="[^"]+">(\w+)</a>$@im', '— [$2]($1)', $description); | ||
253 | } | ||
254 | |||
248 | /** | 255 | /** |
249 | * Replace not whitelisted protocols with http:// in given description. | 256 | * Replace not whitelisted protocols with http:// in given description. |
250 | * | 257 | * |
@@ -289,7 +296,7 @@ function sanitize_html($description) | |||
289 | $description); | 296 | $description); |
290 | } | 297 | } |
291 | $description = preg_replace( | 298 | $description = preg_replace( |
292 | '#(<[^>]+)on[a-z]*="?[^ "]*"?#is', | 299 | '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', |
293 | '$1', | 300 | '$1', |
294 | $description); | 301 | $description); |
295 | return $description; | 302 | return $description; |