Skip to content

Conversation

@justinmk
Copy link
Member

@justinmk justinmk commented Dec 6, 2025

Fix neovim/neovim#36832
Fix #107

Problem:

URLs in help docs may be followed by "." or ",", but it's usually not intended as part of the URL.

Examples from neovim/neovim#36597:

https://luarocks.org,
https://neovim.io/doc/,

Solution:

  • Treat "." as a word.
  • Assume that )]., at the end of a URL is not part of the URL.

Now NESTED parens work:

(https://neovim.io/doc/user/vimfn.html#get()-blob)

but it's not possible to support a trailing closing paren ")":

(https://neovim.io/doc/user/api.html#nvim_input())

workaround: URL-encode the trailing paren:

(https://neovim.io/doc/user/api.html#nvim_input%28%29)

URL cannot contain a closing bracket ] anywhere in the URL. (Workaround: URL-encode the bracket.) This is a tradeoff so that markdown hyperlinks work:

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

Bonus(?): now inline code in this example is recognized:

`foo`.bar

Problem:
URLs in help docs may be followed by "." or ",", but it's usually not
intended as part of the URL.

Examples from neovim/neovim#36597:

    https://luarocks.org,
    https://neovim.io/doc/,

Solution:
- Treat "." as a word.
- Assume that `)].,` at the end of a URL is not part of the URL.

Now NESTED parens work:

    (https://neovim.io/doc/user/vimfn.html#get()-blob)

but it's not possible to support a trailing closing paren ")":

    (https://neovim.io/doc/user/api.html#nvim_input())

workaround: URL-encode the trailing paren:

    (https://neovim.io/doc/user/api.html#nvim_input%28%29)

URL cannot contain a closing bracket `]` anywhere in the URL.
(Workaround: URL-encode the bracket.) This is a tradeoff so that
markdown hyperlinks work:

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

Bonus(?): now the inline code in this example is recognized:

    `foo`.bar
url: (https://neovim.io/doc/user/(foo)#yay)
markdown: [https://neovim.io/doc/user/#yay](https://neovim.io/doc/user/#yay).
url: (https://neovim.io/doc/user/vimfn.html#get()-blob)
markdown: [https://neovim.io/doc/user/#yay[foo](https://neovim.io/doc/user/#yay).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should not try to support "markdown hyperlinks". Can revisit that in a followup, and then ] in URLs will work.

@justinmk
Copy link
Member Author

justinmk commented Dec 6, 2025

CI failures will be fixed by neovim/neovim#36741 .

@justinmk justinmk merged commit fdd4657 into master Dec 6, 2025
0 of 2 checks passed
@justinmk justinmk deleted the fixurl branch December 6, 2025 22:58
justinmk added a commit that referenced this pull request Dec 7, 2025
justinmk added a commit that referenced this pull request Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve URL parsing

2 participants