marked icon indicating copy to clipboard operation
marked copied to clipboard

URLs wrapped in quotes include closing quote

Open sidvishnoi opened this issue 5 years ago • 6 comments

Describe the bug With GFM enabled, URLs wrapped in quotes are linked, but the closing quote is also included in the final output (Lexer output to be precise)

To Reproduce

  1. Marked Demo

Expected behavior The closing quote should not be part of URL as well as linking text.

sidvishnoi avatar Jun 30 '20 21:06 sidvishnoi

A workaround would be to use angle brackets around the url

text "<http://example.com>" text

demo

UziTech avatar Jul 01 '20 03:07 UziTech

Here's another test case for this issue which I encountered in Sourcegraph's UI (uses marked to render error messages)

  • Marked Demo (URL is enclosed by escaped quotes eg. \"http://localhost:3434/v1/list-repos\")
  • Screenshot from Sourcegraph Sourcegraph - URLs wrapped in quotes include closing quote

tohjustin avatar Jun 22 '21 16:06 tohjustin

If the URL is in square brackets and GFM is enabled, then the right square bracket is also part of the generated link. Could this be the same problem?

Example: [http://example.org] Demo

dru1 avatar Feb 22 '22 16:02 dru1

@dru1 it looks like that isn't a valid link in GFM anyway

example: [http://example.com] [http://example.org]

You need angle brackets to make it a link

example: [<http://example.org>] [http://example.org]

UziTech avatar Feb 22 '22 18:02 UziTech

@UziTech Thanks, this might help in my case. Just for clarification: I wonder, if [http://example.com] is not a valid GFM link, why does marked.js display this as a link at all? Shouldn't it just be text?

dru1 avatar Feb 23 '22 08:02 dru1

Yes that is a bug in marked. Unfortunately GFM extensions are very poorly documented so there are a lot of those edge cases that are not defined in the spec.

UziTech avatar Feb 23 '22 16:02 UziTech