microsoft / vscode-markdown-tm-grammar

VS Code built-in markdown extension's Textmate grammar
MIT License
64 stars 49 forks source link

markdown link to file highlight fails for paths with spaces #80

Closed kappanneo closed 2 years ago

kappanneo commented 4 years ago

Steps to Reproduce:

  1. open a new markdown file;
  2. write something such as [text](<path with spaces>) *;
  3. notice how that is highlight differently compared to other links in the form [text](path_without_spaces).

(*angle brackets should allow for links with spaces)

Similar issue: https://github.com/Microsoft/vscode/issues/24763#issue-221783835 Except there the syntax was not complying with the CommonMark spec, while this should.

Again, links work in the PDF visualization, this is a text highlight issue, not a rendering one.

Does this issue occur when all extensions are disabled?: Yes

mjbvz commented 4 years ago

Duplicate of microsoft/vscode#96867 (see that for why it was won't fixed)

mjbvz commented 4 years ago

Or actually, this is a slightly different case. Moving to correct repo

rahul0705 commented 4 years ago

I am unsure exactly how to tackle this one but I think editing https://github.com/microsoft/vscode-markdown-tm-grammar/blob/master/markdown.tmLanguage.base.yaml#L424

          (<?)((?<url>(?>[^\s()]+)|\(\g<url>*\))*)(>?)      # The url

and changing it to:

          (<?)(.*?)(>?)      # The url

might fix the issue (and updating the corresponding captures)? If this is sufficient I can open an MR tackling this issue too.

FYI using https://github.com/textmate/markdown.tmbundle/blob/master/Syntaxes/Markdown.tmLanguage#L241 as inspiration

Edit: for documentation purposes the capture changes would change from:

      '1': {name: punctuation.definition.string.begin.markdown}
      '2': {name: string.other.link.title.markdown}
      '4': {name: punctuation.definition.string.end.markdown}
      '5': {name: punctuation.definition.metadata.markdown}
      '6': {name: punctuation.definition.link.markdown}
      '7': {name: markup.underline.link.markdown}
      '9': {name: punctuation.definition.link.markdown}
      '10': {name: string.other.link.description.title.markdown}
      '11': {name: punctuation.definition.string.begin.markdown}
      '12': {name: punctuation.definition.string.end.markdown}
      '13': {name: string.other.link.description.title.markdown}
      '14': {name: punctuation.definition.string.begin.markdown}
      '15': {name: punctuation.definition.string.end.markdown}
      '16': {name: punctuation.definition.metadata.markdown}

to

      '1': {name: punctuation.definition.string.begin.markdown}
      '2': {name: string.other.link.title.markdown}
      '4': {name: punctuation.definition.string.end.markdown}
      '5': {name: punctuation.definition.metadata.markdown}
      '6': {name: punctuation.definition.link.markdown}
      '7': {name: markup.underline.link.markdown}
      '8': {name: punctuation.definition.link.markdown}
      '9': {name: string.other.link.description.title.markdown}
      '10': {name: punctuation.definition.string.begin.markdown}
      '11': {name: punctuation.definition.string.end.markdown}
      '12': {name: string.other.link.description.title.markdown}
      '13': {name: punctuation.definition.string.begin.markdown}
      '14': {name: punctuation.definition.string.end.markdown}
      '15': {name: punctuation.definition.metadata.markdown}
mjbvz commented 2 years ago

Fixed by 2f9bda284d391f97982f7932ba49eb89b2ac83b1