jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.78k stars 3.39k forks source link

GFM links containing link in label are rendered wrong #10333

Open nsychev opened 4 weeks ago

nsychev commented 4 weeks ago

Explain the problem.

Hi! Thanks for your awesome tool.

I'm trying to convert this link using GFM reader:

[https://example.org](https://example.org)

For example, we can use this command:

echo '[https://example.org](https://example.org)' | pandoc -f gfm -t html

I expect output to be the same as in -f markdown:

<p><a href="https://example.org">https://example.org</a></p>

but instead I get this:

<p>[<a
href="https://example.org](https://example.org)">https://example.org](https://example.org)</a></p>

I think pandoc tries to detect links inside square brackets [...] but shouldn't (when I have https://example. it still works fine, but https://example.o is broken).

Pandoc version?

I have pandoc 3.3 locally and reproduced it at https://pandoc.org/try/

nsychev commented 4 weeks ago

It should be obvious, but the problem is in (enabled by default) extension autolink_bare_uris: if I disable it, everything works fine. But I think it should work even with it being turned on.

jgm commented 4 weeks ago

Yes, agreed. This would need to be changed in jgm/commonmark-hs. And in fact there is already an issue: https://github.com/jgm/commonmark-hs/issues/156

nsychev commented 4 weeks ago

Oh, I looked up only over this repository and was surprised that nobody reported it yet.

Should I close this as a duplicate then?

jgm commented 4 weeks ago

I'll keep this open as a reminder. It would be good to fix this.