stsewd / tree-sitter-rst

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

Literal block parsed as section title if `::` start at a new line #27

Open Carreau opened 2 years ago

Carreau commented 2 years ago

Hello again an apologies as usual for my weirds use case. Note again that this is not a request to fix, but a case where tree-sitter-rst behaves differently than sphinx.

I'm actually happy for tree-sitter-rst to be stricter, but still want to document what I encounter.

Notes
-----
When using ``distutils``, for example in ``setup.py``
::

  import numpy as np

Obviously for the human this a literal block... though, tree-sitter consider the :: as an underline of "When using distutils, for example in setup.py" and make that a title.

Well obviously I think that the :: should be at the end of the line and/or have a blank line before. I'll send a PR to fix upstream, but want to let you know.

stsewd commented 2 years ago

Hi, thanks for reporting! This is kind of related to https://github.com/stsewd/tree-sitter-rst#design-decisions (about the length of the adorments). I may try to test how docutils handles that (don't remember if already did 😅), but in any case if this is always parsed as an independent block by docutils, I can check for this special case.