rsc / markdown

Basic Markdown parser and HTML generator
BSD 3-Clause "New" or "Revised" License
81 stars 4 forks source link

Autolink can't start immediately after `[` #8

Closed matloob closed 8 months ago

matloob commented 8 months ago

From the gfm spec:

All such recognized autolinks can only come at the beginning of a line, after whitespace, or any of the delimiting characters *, _, ~, and (.

Here's a go program that runs markdown and goldmark on the following input: https://go.dev/play/p/kTjBshQ82iQ

[https://golang.org]

Rendered in github as

[https://golang.org]

The output of the program is

markdown:
<p>[<a href="https://golang.org%5D">https://golang.org]</a></p>

goldmark:
<p>[https://golang.org]</p>
rsc commented 8 months ago

The spec is full of lies:

input GitHub
xhttps://go.dev xhttps://go.dev
0https://go.dev 0https://go.dev
%https://go.dev %https://go.dev
αhttps://go.dev αhttps://go.dev
[https://go.dev [https://go.dev
\[https://go.dev [https://go.dev

It is pretty funny that you can have an autolink after a 0 or α or % but not [.

rsc commented 8 months ago

How many of these did you find? I am inclined to leave [https://go.dev] auto-linking, unless people have adopted an idiom of writing [url] to mean "do not link".

matloob commented 8 months ago

I think I saw just one or two on the sample I looked at. I'm okay with leaving this as is

rsc commented 8 months ago

Please reopen if anything changes.