tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
414 stars 52 forks source link

Multiple thematic breaks #31

Closed antistic closed 2 years ago

antistic commented 2 years ago
text 1

---

text 2

---

text 3

does

paragraph [0, 0] - [1, 0]
thematic_break [2, 0] - [3, 0]
paragraph [4, 0] - [5, 0]
  document [4, 0] - [4, 6]
    flow_node [4, 0] - [4, 6]
      plain_scalar [4, 0] - [4, 6]
        string_scalar [4, 0] - [4, 6]
thematic_break [6, 0] - [7, 0]
paragraph [8, 0] - [9, 0]

when I would have expected

paragraph [0, 0] - [1, 0]
thematic_break [2, 0] - [3, 0]
paragraph [4, 0] - [5, 0]
thematic_break [6, 0] - [7, 0]
paragraph [8, 0] - [9, 0]

A smaller example would be

a
***
b
***
paragraph [0, 0] - [1, 0]
thematic_break [1, 0] - [2, 0]
paragraph [2, 0] - [3, 0]
  document [2, 0] - [2, 1]
    flow_node [2, 0] - [2, 1]
      plain_scalar [2, 0] - [2, 1]
        string_scalar [2, 0] - [2, 1]
thematic_break [3, 0] - [4, 0]

instead of

paragraph [0, 0] - [1, 0]
thematic_break [1, 0] - [2, 0]
paragraph [2, 0] - [3, 0]
thematic_break [3, 0] - [4, 0]
a
***
b

works as expected — it's the second break that changes it

MDeiml commented 2 years ago

The content between the thematic breaks is interpreted as a yaml block. This should be fixed by this PR I just made: https://github.com/nvim-treesitter/nvim-treesitter/pull/2501

antistic commented 2 years ago

Thanks so much, it works now!