tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
375 stars 45 forks source link

setext heading level 1 not parsed #59

Open beardedsakimonkey opened 1 year ago

beardedsakimonkey commented 1 year ago

Describe the bug The second heading with = underline isn't highlighted Screen Shot 2022-09-04 at 1 50 29 PM

Code example

title
=====

asdf

title
=====

asdf

Expected behavior maybe something like this?

section [0, 0] - [9, 0]
  setext_heading [0, 0] - [2, 0]
    heading_content: paragraph [0, 0] - [1, 0]
      inline [0, 0] - [0, 5]
    setext_h1_underline [1, 0] - [1, 5]
  paragraph [3, 0] - [4, 0]
    inline [3, 0] - [3, 4]
  section [5, 0] - [9, 0]
    setext_heading [5, 0] - [7, 0]
      heading_content: paragraph [5, 0] - [6, 0]
        inline [5, 0] - [5, 5]
      setext_h1_underline [6, 0] - [6, 5]
    paragraph [8, 0] - [9, 0]
      inline [8, 0] - [8, 4]

Actual behavior

section [0, 0] - [9, 0]
  setext_heading [0, 0] - [2, 0]
    heading_content: paragraph [0, 0] - [1, 0]
      inline [0, 0] - [0, 5]
    setext_h1_underline [1, 0] - [1, 5]
  paragraph [3, 0] - [4, 0]
    inline [3, 0] - [3, 4]
  paragraph [5, 0] - [6, 0]
    inline [5, 0] - [5, 5]
  paragraph [6, 0] - [7, 0]
    inline [6, 0] - [6, 5]
  paragraph [8, 0] - [9, 0]
    inline [8, 0] - [8, 4]
MDeiml commented 1 year ago

This is a problem I introduced by adding "section" nodes. I excluded setext headings from that logic as a workaround. This means sections don't behave nicely with setext headings now, but they're not very important, so this is probably the better (hopefully temporary) solution.