Skip to content

bug: link_destination should not include <> #174

@tbung

Description

@tbung

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

The destination in an inline link can be enclosed in angle braces, so the link can include whitespace. According to the spec, the angle braces do not belong to the link destination:

a sequence of zero or more characters between an opening < and a closing > that contains no line endings or unescaped < or > characters

It also makes semantic sense, that what ever is parsed as link_destination can be used as a file path or url. This is also the context this came up in, because neovim tries to open the url with the angle braces (see nvim-treesitter/nvim-treesitter#7369).

I have a crude fix ready and will submit a pull request once I wrote a test, if you agree that this should be changed.

Steps To Reproduce/Bad Parse Tree

[example](<https://example.com>)

gets parsed as

(inline [0, 0] - [1, 0]
  (inline_link [0, 0] - [0, 32]
    (link_text [0, 1] - [0, 8])
    (link_destination [0, 10] - [0, 31])))

Expected Behavior/Parse Tree

(inline [0, 0] - [1, 0]
  (inline_link [0, 0] - [0, 32]
    (link_text [0, 1] - [0, 8])
    (link_destination [0, 11] - [0, 30])))

Repro

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions