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