]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - plugins/markdown/markdown.php
Fix hashtags with markdown escape enabled
[github/shaarli/Shaarli.git] / plugins / markdown / markdown.php
index 821bb12511bf15b98aba0dab6b757c0fc15079a5..21972814c046182f3e818a83787ff92111e96d19 100644 (file)
@@ -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(
+                '#<a href="([^ ]*)"'. $hashtagTitle .'>([^<]+)</a>#m',
+                '[$2]($1)',
+                $descriptionLine
+            );
+        }
+
         $descriptionOut .= $descriptionLine;
         if ($lineCount++ < count($descriptionLines) - 1) {
             $descriptionOut .= PHP_EOL;