stsewd / tree-sitter-rst

reStructuredText grammar for tree-sitter
https://stsewd.dev/tree-sitter-rst/
MIT License
50 stars 7 forks source link

Grammar sometimes treats numbered lists as definition lists #14

Open cpkio opened 2 years ago

cpkio commented 2 years ago
- there are many variations of passages of lorem ipsum available, but the
  majority have suffered alteration in some form, by injected humour, or
  randomised words which don't look even slightly believable.

- there are many variations of passages of lorem ipsum available, but the
  majority have suffered alteration in some form, by injected humour, or
  randomised words which don't look even slightly believable.

- there are many variations of passages of lorem ipsum available, but the
  majority have suffered alteration in some form, by injected humour, or
  randomised words which don't look even slightly believable.

There are many variations of passages of Lorem Ipsum available, but the
majority have suffered alteration in some form, by injected humour, or
randomised words which don't look even slightly believable.

1. There are many variations of passages of Lorem Ipsum available, but the
   majority have suffered alteration in some form, by injected humour, or
   randomised words which don't look even slightly believable.

2. There are many variations of Lorem Ipsum available, but the majority have
   suffered alteration in some form, by injected humour, or randomised words
   which don't look even slightly believable.

3. There are many variations of passages of Lorem Ipsum available, but the
   majority have suffered in some form, by injected humour, or randomised
   words don't look even slightly believable.

Using gwis or gwip on any of these list items will eventually lead to first line of them be recognized as definition list term (mostly because definition list is allowed by grammar to start from a number or a bullet I suppose).

The reference says these lists are correct:

List item bodies must be left-aligned and indented relative to the bullet; the text immediately after the bullet determines the indentation. For example:

- This is the first bullet list item.  The blank line above the
  first list item is required; blank lines between list items
  (such as below this paragraph) are optional.

- This is the first paragraph in the second item in the list.

  This is the second paragraph in the second item in the list.
  The blank line above this paragraph is required.  The left edge
  of this paragraph lines up with the paragraph above, both
  indented relative to the bullet.

  - This is a sublist.  The bullet lines up with the left edge of
    the text blocks above.  A sublist is a new list so requires a
    blank line above and below.

- This is the third item of the main list.

This paragraph is not part of the list.
stsewd commented 2 years ago

Hi, I'm not able to replicate this with your example

Screenshot 2021-09-25 at 17-54-52 reStructuredText grammar for tree-sitter - tree-sitter-rst

the CST is correctly generated. I think you may have some whitespaces that github is removing, would be better if you share it as a file.

cpkio commented 2 years ago

TS Playground does not replace Neovim practice.

I've created an isolated environment, with only TS (+rst grammar) and TSPlayground plugins installed. Then I'm opening test file, TSPlayground panel, bind gwip to for speed and you can see unumbered and then numbered lists turning into terms lists on <A-q> press.

2021-09-26_20-44-08

stsewd commented 2 years ago

Hmmm, that's interesting, I wasn't aware of gw, looks like it formats the line to respect the textwidth option. Anyway, don't think this is a problem with the grammar, but a bug on neovim, after saving and reloading the buffer the correct tree is shown.

stsewd commented 8 months ago

This is the same problem as https://github.com/stsewd/tree-sitter-rst/issues/44.