aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/markdown
diff options
context:
space:
mode:
authorAurélien Tamisier <virtualtam+github@flibidi.net>2018-12-02 22:47:41 +0100
committerGitHub <noreply@github.com>2018-12-02 22:47:41 +0100
commit1004742f09b55ff781c13745781b9a7e90986faa (patch)
treeaa0e5743390296441edf09f44f95b3d21f2b5a16 /plugins/markdown
parent5e0a898bb13fad528514b0d33763bcaae38b45b0 (diff)
parent9d9f6d75b94aab51067bdfbe50b58b66d1194f6d (diff)
downloadShaarli-1004742f09b55ff781c13745781b9a7e90986faa.tar.gz
Shaarli-1004742f09b55ff781c13745781b9a7e90986faa.tar.zst
Shaarli-1004742f09b55ff781c13745781b9a7e90986faa.zip
Merge pull request #1234 from virtualtam/lint
Setup PHPCS and cleanup linter configuration
Diffstat (limited to 'plugins/markdown')
-rw-r--r--plugins/markdown/markdown.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php
index 08e64dae..8823af91 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -139,7 +139,6 @@ function hook_markdown_render_includes($data)
139 || $data['_PAGE_'] == Router::$PAGE_DAILY 139 || $data['_PAGE_'] == Router::$PAGE_DAILY
140 || $data['_PAGE_'] == Router::$PAGE_EDITLINK 140 || $data['_PAGE_'] == Router::$PAGE_EDITLINK
141 ) { 141 ) {
142
143 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; 142 $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css';
144 } 143 }
145 144
@@ -195,8 +194,7 @@ function reverse_text2clickable($description)
195 // Detect and toggle block of code 194 // Detect and toggle block of code
196 if (!$codeBlockOn) { 195 if (!$codeBlockOn) {
197 $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; 196 $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0;
198 } 197 } elseif (preg_match('/^```/', $descriptionLine) > 0) {
199 elseif (preg_match('/^```/', $descriptionLine) > 0) {
200 $codeBlockOn = false; 198 $codeBlockOn = false;
201 } 199 }
202 200
@@ -302,13 +300,17 @@ function sanitize_html($description)
302 foreach ($escapeTags as $tag) { 300 foreach ($escapeTags as $tag) {
303 $description = preg_replace_callback( 301 $description = preg_replace_callback(
304 '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is', 302 '#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is',
305 function ($match) { return escape($match[0]); }, 303 function ($match) {
306 $description); 304 return escape($match[0]);
305 },
306 $description
307 );
307 } 308 }
308 $description = preg_replace( 309 $description = preg_replace(
309 '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', 310 '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is',
310 '$1', 311 '$1',
311 $description); 312 $description
313 );
312 return $description; 314 return $description;
313} 315}
314 316
@@ -341,7 +343,7 @@ function process_markdown($description, $escape = true, $allowedProtocols = [])
341 ->text($processedDescription); 343 ->text($processedDescription);
342 $processedDescription = sanitize_html($processedDescription); 344 $processedDescription = sanitize_html($processedDescription);
343 345
344 if(!empty($processedDescription)){ 346 if (!empty($processedDescription)) {
345 $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; 347 $processedDescription = '<div class="markdown">'. $processedDescription . '</div>';
346 } 348 }
347 349