💾 Archived View for gmi.noulin.net › gitRepositories › md4c › file › test › permissive-www-autolinks… captured on 2024-08-18 at 18:50:29. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
permissive-www-autolinks.txt (3631B)
1 2 # Permissive WWW Autolinks 3 4 With the flag `MD_FLAG_PERMISSIVEWWWAUTOLINKS`, MD4C enables recognition of 5 autolinks starting with `www.`, even if they do not exactly follow the syntax 6 of autolink as specified in CommonMark specification. 7 8 These do not have to be enclosed in `<` and `>`, and they even do not need 9 any preceding scheme specification. 10 11 The WWW autolink will be recognized when a valid domain is found. 12 13 A valid domain consists of the text `www.`, followed by alphanumeric characters, 14 nderscores (`_`), hyphens (`-`) and periods (`.`). There must be at least one 15 period, and no underscores may be present in the last two segments of the domain. 16 17 The scheme `http` will be inserted automatically: 18 19 ```````````````````````````````` example 20 www.commonmark.org 21 . 22 <p><a href="http://www.commonmark.org">www.commonmark.org</a></p> 23 ```````````````````````````````` 24 25 After a valid domain, zero or more non-space non-`<` characters may follow: 26 27 ```````````````````````````````` example 28 Visit www.commonmark.org/help for more information. 29 . 30 <p>Visit <a href="http://www.commonmark.org/help">www.commonmark.org/help</a> for more information.</p> 31 ```````````````````````````````` 32 33 We then apply extended autolink path validation as follows: 34 35 Trailing punctuation (specifically, `?`, `!`, `.`, `,`, `:`, `*`, `_`, and `~`) 36 will not be considered part of the autolink, though they may be included in the 37 interior of the link: 38 39 ```````````````````````````````` example 40 Visit www.commonmark.org. 41 42 Visit www.commonmark.org/a.b. 43 . 44 <p>Visit <a href="http://www.commonmark.org">www.commonmark.org</a>.</p> 45 <p>Visit <a href="http://www.commonmark.org/a.b">www.commonmark.org/a.b</a>.</p> 46 ```````````````````````````````` 47 48 When an autolink ends in `)`, we scan the entire autolink for the total number 49 of parentheses. If there is a greater number of closing parentheses than 50 opening ones, we don't consider the last character part of the autolink, in 51 order to facilitate including an autolink inside a parenthesis: 52 53 ```````````````````````````````` example 54 www.google.com/search?q=Markup+(business) 55 56 (www.google.com/search?q=Markup+(business)) 57 . 58 <p><a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a></p> 59 <p>(<a href="http://www.google.com/search?q=Markup+(business)">www.google.com/search?q=Markup+(business)</a>)</p> 60 ```````````````````````````````` 61 62 This check is only done when the link ends in a closing parentheses `)`, so if 63 the only parentheses are in the interior of the autolink, no special rules are 64 applied: 65 66 ```````````````````````````````` example 67 www.google.com/search?q=(business))+ok 68 . 69 <p><a href="http://www.google.com/search?q=(business))+ok">www.google.com/search?q=(business))+ok</a></p> 70 ```````````````````````````````` 71 72 If an autolink ends in a semicolon (`;`), we check to see if it appears to 73 resemble an [entity reference][entity references]; if the preceding text is `&` 74 followed by one or more alphanumeric characters. If so, it is excluded from 75 the autolink: 76 77 ```````````````````````````````` example 78 www.google.com/search?q=commonmark&hl=en 79 80 www.google.com/search?q=commonmark&hl; 81 . 82 <p><a href="http://www.google.com/search?q=commonmark&hl=en">www.google.com/search?q=commonmark&hl=en</a></p> 83 <p><a href="http://www.google.com/search?q=commonmark">www.google.com/search?q=commonmark</a>&hl;</p> 84 ```````````````````````````````` 85 86 `<` immediately ends an autolink. 87 88 ```````````````````````````````` example 89 www.commonmark.org/he<lp 90 . 91 <p><a href="http://www.commonmark.org/he">www.commonmark.org/he</a><lp</p> 92 ````````````````````````````````