tpope / vim-markdown

Vim Markdown runtime files
1.22k stars 191 forks source link

Mistook todo checkbox as a markdown link #212

Closed VimWei closed 3 months ago

VimWei commented 4 months ago

Environment

I use the built-in markdown plugin with gvim 9.1, without installing any third-party markdown filetype plugins.

Issue reproduction

  1. :new
  2. :set filetype=markdown
  3. Add a space (just one space) and a markdown link after a todo checkbox:

* [x] [test](https://www.example.com)

We can see vim mistook todo checkbox [x] as a markdown link, and the x will be underlined.

image

augroup MarkdownLinkConceal
    autocmd!
    autocmd FileType markdown
        \ syn region markdownLink matchgroup=markdownLinkDelimiter
        \ start="(" end=")" contains=markdownUrl keepend contained conceal
    autocmd FileType markdown
        \ syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
        \ start="!\=\[\%(\_[^][]*\%(\[\_[^][]*\]\_[^][]*\)*]\%( \=[[(]\)\)\@="
        \ end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite
        \ contains=@markdownInline,markdownLineStart concealends
augroup END

image

* [x] [test](https://www.example.com)

image

image

Reference

tpope commented 3 months ago

I made a deliberate decision in https://github.com/tpope/vim-markdown/commit/6c1e41e4c4d95ccb024530d957c583ab807b5724 to allow a space in [link] (url). I've long since forgotten why, but it's a safe bet that it was in reaction to some parser. I guess I'll try tightening it up a bit.

VimWei commented 3 months ago

Thanks!