A Markdown shard for the Crystal programming language
Revision | b78946ce53d23b0225ed0c09b64165b935f45b0d (tree) |
---|---|
Zeit | 2023-11-26 09:53:57 |
Autor | supercell <stigma@disr...> |
Commiter | supercell |
Fix start of line detection in AutolinkExtension
@@ -10,6 +10,7 @@ All notable changes to Luce will be documented in this file. | ||
10 | 10 | * This will raise an exception should an infinite loop begin during `BlockSyntax#parse_lines`. |
11 | 11 | * Fix an obscure issue with `HTMLBlockSyntax`. |
12 | 12 | * Fix tables not rendering when there are trailing spaces. |
13 | +* Fix beginning of line detection in `AutolinkExtensionSyntax`. | |
13 | 14 | |
14 | 15 | ## [0.4.0] - 2023-05-23 |
15 | 16 |
@@ -1,4 +1,10 @@ | ||
1 | 1 | >>> not a link |
2 | 2 | mhttp://www.foo.com |
3 | 3 | <<< |
4 | -<p>mhttp://www.foo.com</p> | |
\ No newline at end of file | ||
4 | +<p>mhttp://www.foo.com</p> | |
5 | +>>> following a newline | |
6 | +m | |
7 | +http://www.foo.com | |
8 | +<<< | |
9 | +<p>m | |
10 | +<a href="http://www.foo.com">http://www.foo.com</a></p> | |
\ No newline at end of file |
@@ -52,12 +52,12 @@ module Luce | ||
52 | 52 | return false |
53 | 53 | end |
54 | 54 | |
55 | - # When it is a link and it is not preceded by `*`, `_`, `~`, `(`, or `>`, | |
56 | - # it is invalid. See | |
57 | - # https://github.github.io/gfm/#extended-autolink-path-validation | |
55 | + # When it is a link and it is not at the beginning of a line, or preceded | |
56 | + # by whitespace, `*`, `_`, `~`, `(`, or `>`, it is invalid. See | |
57 | + # https://github.github.io/gfm/#autolinks-extension-. | |
58 | 58 | if start_match[1]? != nil && parser.pos > 0 |
59 | 59 | preceded_by = parser.char_at(parser.pos - 1).chr |
60 | - valid_preceding_chars = [' ', '*', '_', '~', '(', '>'] | |
60 | + valid_preceding_chars = ['\n', ' ', '*', '_', '~', '(', '>'] | |
61 | 61 | return false unless valid_preceding_chars.includes? preceded_by |
62 | 62 | end |
63 | 63 |