stsewd / tree-sitter-rst

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

Title with bullet is parsed as a list followed by a transition #30

Closed Carreau closed 2 years ago

Carreau commented 2 years ago

As usual documenting an edge case that I encountered somewhere, not a request to fix, I'll try to send a fix upstream.

This

2) Intrinsic NumPy array creation functions
===========================================
..
  40 functions seems like a small number, but the routies.array-creation
  has ~47. I'm sure there are more. 

the ===== is seen as the title and .. as the underline I beleive.

stsewd commented 2 years ago

Looks like the main problem is that the previous title is being parsed as a list followed by a transition instead of a title.

2) Intrinsic NumPy array creation functions
===========================================
enumerated_list [0, 0] - [0, 43]
  list_item [0, 0] - [0, 43]
    body [0, 3] - [0, 43]
      paragraph [0, 3] - [0, 43]
transition [1, 0] - [1, 43]

Without the number, it is parsed correctly

Intrinsic NumPy array creation functions
========================================
..
  40 functions seems like a small number, but the routies.array-creation
  has ~47. I'm sure there are more. 
section [0, 0] - [1, 40]
  title [0, 0] - [0, 40]
comment [2, 0] - [4, 35]
stsewd commented 2 years ago

So, looks like for docutils this is invalid

2) Intrinsic NumPy array creation functions
3) Intrinsic NumPy array creation functions
===========================================
1) Intrinsic NumPy array creation functions

===========================================

Next text

So, transitions require to be separated by a blank line (titles don't have this restriction)