diff options
Diffstat (limited to 'plugins/markdown/markdown.php')
-rw-r--r-- | plugins/markdown/markdown.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index 6b1c1d44..a764b6fa 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -6,8 +6,6 @@ | |||
6 | * Shaare's descriptions are parsed with Markdown. | 6 | * Shaare's descriptions are parsed with Markdown. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | require_once 'Parsedown.php'; | ||
10 | |||
11 | /* | 9 | /* |
12 | * If this tag is used on a shaare, the description won't be processed by Parsedown. | 10 | * If this tag is used on a shaare, the description won't be processed by Parsedown. |
13 | */ | 11 | */ |
@@ -157,8 +155,9 @@ function reverse_text2clickable($description) | |||
157 | $lineCount = 0; | 155 | $lineCount = 0; |
158 | 156 | ||
159 | foreach ($descriptionLines as $descriptionLine) { | 157 | foreach ($descriptionLines as $descriptionLine) { |
160 | // Detect line of code | 158 | // Detect line of code: starting with 4 spaces, |
161 | $codeLineOn = preg_match('/^ /', $descriptionLine) > 0; | 159 | // except lists which can start with +/*/- or `2.` after spaces. |
160 | $codeLineOn = preg_match('/^ +(?=[^\+\*\-])(?=(?!\d\.).)/', $descriptionLine) > 0; | ||
162 | // Detect and toggle block of code | 161 | // Detect and toggle block of code |
163 | if (!$codeBlockOn) { | 162 | if (!$codeBlockOn) { |
164 | $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; | 163 | $codeBlockOn = preg_match('/^```/', $descriptionLine) > 0; |
@@ -175,10 +174,10 @@ function reverse_text2clickable($description) | |||
175 | $descriptionLine | 174 | $descriptionLine |
176 | ); | 175 | ); |
177 | 176 | ||
178 | // Reverse hashtag links if we're in a code block. | 177 | // Reverse all links in code blocks, only non hashtag elsewhere. |
179 | $hashtagFilter = ($codeBlockOn || $codeLineOn) ? $hashtagTitle : ''; | 178 | $hashtagFilter = (!$codeBlockOn && !$codeLineOn) ? '(?!'. $hashtagTitle .')': '(?:'. $hashtagTitle .')?'; |
180 | $descriptionLine = preg_replace( | 179 | $descriptionLine = preg_replace( |
181 | '!<a href="[^ ]*"'. $hashtagFilter .'>([^<]+)</a>!m', | 180 | '#<a href="[^ ]*"'. $hashtagFilter .'>([^<]+)</a>#m', |
182 | '$1', | 181 | '$1', |
183 | $descriptionLine | 182 | $descriptionLine |
184 | ); | 183 | ); |