2 unstable releases

0.2.0 Feb 24, 2025
0.1.0 Aug 26, 2022

#518 in Text editors

Download history 8/week @ 2024-11-25 19/week @ 2024-12-02 16/week @ 2024-12-09 9/week @ 2025-01-06 7/week @ 2025-01-13 1/week @ 2025-01-20 2/week @ 2025-01-27 5/week @ 2025-02-10 1/week @ 2025-02-17 133/week @ 2025-02-24 17/week @ 2025-03-03

152 downloads per month
Used in cbfmt

MIT license

405KB
13K SLoC

C 12K SLoC // 0.0% comments JavaScript 330 SLoC // 0.5% comments Rust 32 SLoC // 0.1% comments

tree-sitter-rst

CI

reStructuredText grammar for tree-sitter. Based on the specification from https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html.

Check the playground at https://stsewd.dev/tree-sitter-rst/.

Note: this grammar is still under development, a lot of things may change!

TODO

  • Allow lists with blank lines between items
  • Refactor parse citation and footer reference
  • Nested line blocks
  • Option lists
  • Add some nodes to inline?
  • Check if there is a way to re-implement some nodes to JS instead of C?
  • A definition list with classifiers can't be separated by a blank line.
  • tests, tests, and more tests!

Design notes

  • Nodes that contain body elements inside (like lists or directives), are inside a node named body.
  • In RST sections are a big node that contains body elements, here they are just a node containing the title. This is to avoid guessing the level of subtitles.
  • In RST standalone hyperlinks are reference nodes, here they are standalone_hyperlink nodes. This is to avoid confusion with inline references nodes (that are a reference node).
  • Literal blocks are part of the paragraph they precede, not a separate node, except for the expanded form of literal blocks.
  • In rst directives only have "body" node, here the body is parsed as arguments/options/content.

Design decisions

Projects using this grammar

Contributing

Check the CONTRIBUTING.md file

Other grammars

Dependencies

~4–280KB