From 1c633d74d931b97bf419aa18141636fe4414bd92 Mon Sep 17 00:00:00 2001 From: Antonin Date: Tue, 10 May 2016 17:53:06 +0200 Subject: [PATCH] Using the library --- app/classes/Framadate/Utils.php | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php index dba51d6..884b2d7 100644 --- a/app/classes/Framadate/Utils.php +++ b/app/classes/Framadate/Utils.php @@ -134,30 +134,13 @@ class Utils { } public static function markdown($md, $clear) { - preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $md, $md_a_img); // Markdown [![alt](src)](href) - preg_match_all('/!\[(.*?)\]\((.*?)\)/', $md, $md_img); // Markdown ![alt](src) - preg_match_all('/\[(.*?)\]\((.*?)\)/', $md, $md_a); // Markdown [text](href) - if (isset($md_a_img[2][0]) && $md_a_img[2][0] != '' && isset($md_a_img[3][0]) && $md_a_img[3][0] != '') { // [![alt](src)](href) + $parseDown = new \Parsedown(); - $text = self::htmlEscape($md_a_img[1][0]); - $html = '' . $text . ''; + $html = $parseDown + ->setMarkupEscaped(true) + ->line($md); - } elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src) - - $text = self::htmlEscape($md_img[1][0]); - $html = '' . $text . ''; - - } elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href) - - $text = self::htmlEscape($md_a[1][0]); - $html = '' . $text . ''; - - } else { // text only - - $text = self::htmlEscape($md); - $html = $text; - - } + $text = strip_tags($html); return $clear ? $text : $html; }