tree-sitter-vimdoc icon indicating copy to clipboard operation
tree-sitter-vimdoc copied to clipboard

codeblock adjacent to list item is not recognized

Open echasnovski opened this issue 5 months ago • 2 comments

Example:

- Line starts with dash:
>
 This is not recognized as code block
<

This seems to be a known problem, but there is no issue to track it and for users to consult with.

I tried to fix this, but the assumption that code block is not contiguous to list item seems to be too much entangled in the grammar itself. So looks like it would at least require serious refactor if at all possible.

The current workaround is to have a blank link after list item text block (contiguous lines without blank lines with first starting with list prefix). So this will work:

- Line starts with dash:

>
 This is recognized as code block
<

echasnovski avatar Jan 23 '24 09:01 echasnovski

Looks like Vim's help syntax "supports" this (but it has no concept of list-items, which is a major feature of tree-sitter-vimdoc).

The general idea in tree-sitter-vimdoc is that "blocks" are separated by a blank line. In the given example, the > immediately follows the list-item thus it would be part of the list-item (if this bug didn't exist), not a separate block. But it looks like you expect it to be a separate block?

Note that this does work (in both Vim-syntax and tree-sitter-vimdoc):

- Line starts with dash: >
  code line1
  code line2
<

justinmk avatar Jan 23 '24 18:01 justinmk

But it looks like you expect it to be a separate block?

I would expect that codeblock formatting would take precedence over list items, yes. Mostly because it is supported in Vim's help and in Markdown.

Note that this does work (in both Vim-syntax and tree-sitter-vimdoc):

Yes, this is a better solution as it allows to add only single blank line at the top of code block (similar to the one in the initial comment). I thought I tried it before and it did not work. Apparently, missed something.

This feels like a decent workaround, though. Now the original example only looks like inconsistency and not like a big issue.

echasnovski avatar Jan 23 '24 19:01 echasnovski