stsewd / tree-sitter-rst

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

Allow blank line between list items ? #29

Open Carreau opened 2 years ago

Carreau commented 2 years ago

It looks like tree-sitter-rst is a bit greedy in deciding to construct a new Enumerated/Bullet list. I think allowing to add blank lines between items would be good.

1. first Enumerated list item

   * bullet
   * bullet
   * bullet
2. second Enumerated list item

   * actually a full bullet list

   * actually a full bullet list

   * actually a  full bullet list

3. Actually First item of a new enumerate list

   * actually a full bullet list

   * actually a full bullet list

   * actually a  full bullet list

I think that for my project I can locally fix it is two consecutive nodes are of the same list type, merge them.

as for other issues, I'm happy to take a shot at it, but I might need pointers.

stsewd commented 2 years ago

Sorry for the late reply, yeah, this is on my todos https://github.com/stsewd/tree-sitter-rst#todo, the main thing I had problems with was that lists are kind of a special block element, all other block elements are separated by a blank line, but lists can continue after a blank line, and they also can start a new list if the bullet is different, like

* one

* two

- three

Those are two lists! But I could try to solve the first problem at least, for the second I'll need to give each bullet its own node probably

Carreau commented 2 years ago

Ah sorry I missed the todo. And good point for the different bullet.

Currently I just have an extra pass, that combine successive identical lists, so that's fine. When I find some time to learn tree-sitter, I can give a shot at fixing it.