Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: link_destination should not include <> #174

Open
2 tasks done
tbung opened this issue Nov 17, 2024 · 1 comment · May be fixed by #175
Open
2 tasks done

bug: link_destination should not include <> #174

tbung opened this issue Nov 17, 2024 · 1 comment · May be fixed by #175
Labels
bug Something isn't working

Comments

@tbung
Copy link

tbung commented Nov 17, 2024

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

@tbung
Copy link
Author

tbung commented Nov 17, 2024

Actually I have no idea how to create additional tests for this, as far as I understand tests do not support ranges or anonymous nodes. Let me know if there is a way I am not seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant