From 50142efd1b4b826f60b1e5673dba5ccbe26e0108 Mon Sep 17 00:00:00 2001 From: kalvn Date: Thu, 1 Feb 2018 13:16:58 +0100 Subject: Executes daily hooks before creating columns. --- plugins/markdown/markdown.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'plugins/markdown/markdown.php') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 1531549d..6b4aabf3 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -70,19 +70,18 @@ function hook_markdown_render_feed($data, $conf) */ function hook_markdown_render_daily($data, $conf) { + //var_dump($data);die; // Manipulate columns data - foreach ($data['cols'] as &$value) { - foreach ($value as &$value2) { - if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) { - $value2 = stripNoMarkdownTag($value2); - continue; - } - $value2['formatedDescription'] = process_markdown( - $value2['formatedDescription'], - $conf->get('security.markdown_escape', true), - $conf->get('security.allowed_protocols') - ); + foreach ($data['linksToDisplay'] as &$value) { + if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { + $value = stripNoMarkdownTag($value); + continue; } + $value['formatedDescription'] = process_markdown( + $value['formatedDescription'], + $conf->get('security.markdown_escape', true), + $conf->get('security.allowed_protocols') + ); } return $data; @@ -136,7 +135,7 @@ function hook_markdown_render_includes($data) || $data['_PAGE_'] == Router::$PAGE_DAILY || $data['_PAGE_'] == Router::$PAGE_EDITLINK ) { - + $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; } -- cgit v1.2.3 From b525810c14a5602f11949a40529f6a809c29b679 Mon Sep 17 00:00:00 2001 From: Dennis Verspuij Date: Mon, 19 Mar 2018 10:01:20 +0000 Subject: Fix removal of on=... attributes from html generated from markdown --- plugins/markdown/markdown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/markdown/markdown.php') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 6b4aabf3..2f24e417 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -288,7 +288,7 @@ function sanitize_html($description) $description); } $description = preg_replace( - '#(<[^>]+)on[a-z]*="?[^ "]*"?#is', + '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', '$1', $description); return $description; -- cgit v1.2.3 From dd6794cff8a1f26c4d08544d89e1df1f521dcb26 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 19 May 2018 12:55:43 +0200 Subject: Fix feed permalink rendering with markdown escape set to true Fixes #1134 --- plugins/markdown/markdown.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins/markdown/markdown.php') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 2f24e417..821bb125 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -6,6 +6,8 @@ * Shaare's descriptions are parsed with Markdown. */ +use Shaarli\Config\ConfigManager; + /* * If this tag is used on a shaare, the description won't be processed by Parsedown. */ @@ -50,6 +52,7 @@ function hook_markdown_render_feed($data, $conf) $value = stripNoMarkdownTag($value); continue; } + $value['description'] = reverse_feed_permalink($value['description']); $value['description'] = process_markdown( $value['description'], $conf->get('security.markdown_escape', true), @@ -244,6 +247,11 @@ function reverse_space2nbsp($description) return preg_replace('/(^| ) /m', '$1 ', $description); } +function reverse_feed_permalink($description) +{ + return preg_replace('@— (\w+)$@im', '— [$2]($1)', $description); +} + /** * Replace not whitelisted protocols with http:// in given description. * -- cgit v1.2.3 From a120fb2977331e0f7d7ffe05861ba179fdae8764 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 13 Aug 2018 10:42:27 +0200 Subject: Add OpenGraph meta tags on permalink page Includes: - og:title - og:type -> article - og:image -> if there is a thumbnail - og:url -> permalink - og:description -> first 300 chars of raw description - article:published_time - article:modified_time - article:tag -> one OG meta tag for each shaare tag Fixes #258 --- plugins/markdown/markdown.php | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/markdown/markdown.php') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 821bb125..d4fb1f76 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -28,6 +28,7 @@ function hook_markdown_render_linklist($data, $conf) $value = stripNoMarkdownTag($value); continue; } + $value['description_src'] = $value['description']; $value['description'] = process_markdown( $value['description'], $conf->get('security.markdown_escape', true), -- cgit v1.2.3 From cb7940e2deacba66f2510816732be654b255cc70 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 14 Aug 2018 12:26:51 +0200 Subject: Fix hashtags with markdown escape enabled They're now transformed to markdown syntax links before processing them through Parsedown. Fixes #1210 --- plugins/markdown/markdown.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins/markdown/markdown.php') diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 821bb125..21972814 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php @@ -215,6 +215,15 @@ function reverse_text2clickable($description) $descriptionLine ); + // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true + if (!$codeBlockOn && !$codeLineOn) { + $descriptionLine = preg_replace( + '#([^<]+)#m', + '[$2]($1)', + $descriptionLine + ); + } + $descriptionOut .= $descriptionLine; if ($lineCount++ < count($descriptionLines) - 1) { $descriptionOut .= PHP_EOL; -- cgit v1.2.3 From a0ab3c3f68ed3bca7d218e6e5847820b82b086ca Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 00:22:45 +0200 Subject: lint: apply phpcbf to plugins/ Signed-off-by: VirtualTam --- plugins/markdown/markdown.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'plugins/markdown/markdown.php') 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) || $data['_PAGE_'] == Router::$PAGE_DAILY || $data['_PAGE_'] == Router::$PAGE_EDITLINK ) { - $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css'; } @@ -195,8 +194,7 @@ function reverse_text2clickable($description) // Detect and toggle block of code if (!$codeBlockOn) { $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; - } - elseif (preg_match('/^```/', $descriptionLine) > 0) { + } elseif (preg_match('/^```/', $descriptionLine) > 0) { $codeBlockOn = false; } @@ -302,13 +300,17 @@ function sanitize_html($description) foreach ($escapeTags as $tag) { $description = preg_replace_callback( '#<\s*'. $tag .'[^>]*>(.*]*>)?#is', - function ($match) { return escape($match[0]); }, - $description); + function ($match) { + return escape($match[0]); + }, + $description + ); } $description = preg_replace( '#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is', '$1', - $description); + $description + ); return $description; } @@ -341,7 +343,7 @@ function process_markdown($description, $escape = true, $allowedProtocols = []) ->text($processedDescription); $processedDescription = sanitize_html($processedDescription); - if(!empty($processedDescription)){ + if (!empty($processedDescription)) { $processedDescription = '
'. $processedDescription . '
'; } -- cgit v1.2.3