Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: image markdown incorrectly parsed when more than 8 images are on adjacent lines #186

Open
2 tasks done
marchyman opened this issue Feb 24, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@marchyman
Copy link

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

Tree-sitter parses an image link ![alt text](url-or-file-path) as an inline_link when the image link is followed by 8 more images. 8 images in a row will parse correctly. The first image will be parsed incorrect if a 9th image is added. If a 10th image is added the 2nd image will be parsed incorrectly, etc. Breaking the set of images up into groups of 8 or less by adding empty lines results in a correct tree.

I am not a tree-sitter user save that I am an nvim user. I discovered this using the nvim InspectTree command when trying to figure out a side effect of this bug.

Steps To Reproduce/Bad Parse Tree

Create a markdown file containing 9 or more image links
Parse the file
Inspect the resulting tree.

Expected Behavior/Parse Tree

This is the result when parsing a file containing 9 image lines.

(document ; [0, 0] - [9, 0]
  (section ; [0, 0] - [9, 0]
    (paragraph ; [0, 0] - [9, 0]
      (inline ; [0, 0] - [8, 16]
        (inline ; [0, 0] - [8, 16]
          (inline_link ; [0, 1] - [0, 16]    <=== this is incorrect, it should be (image ; ...
            (link_text) ; [0, 2] - [0, 5]
            (link_destination)) ; [0, 7] - [0, 15]
          (image ; [1, 0] - [1, 16]
            (image_description) ; [1, 2] - [1, 5]
            (link_destination)) ; [1, 7] - [1, 15]
          (image ; [2, 0] - [2, 16]
            (image_description) ; [2, 2] - [2, 5]
            (link_destination)) ; [2, 7] - [2, 15]
          (image ; [3, 0] - [3, 16]
            (image_description) ; [3, 2] - [3, 5]
            (link_destination)) ; [3, 7] - [3, 15]
          (image ; [4, 0] - [4, 16]
            (image_description) ; [4, 2] - [4, 5]
            (link_destination)) ; [4, 7] - [4, 15]
          (image ; [5, 0] - [5, 16]
            (image_description) ; [5, 2] - [5, 5]
            (link_destination)) ; [5, 7] - [5, 15]
          (image ; [6, 0] - [6, 16]
            (image_description) ; [6, 2] - [6, 5]
            (link_destination)) ; [6, 7] - [6, 15]
          (image ; [7, 0] - [7, 16]
            (image_description) ; [7, 2] - [7, 5]
            (link_destination)) ; [7, 7] - [7, 15]
          (image ; [8, 0] - [8, 16]
            (image_description) ; [8, 2] - [8, 5]
            (link_destination))))))) ; [8, 7] - [8, 15]

The input file contained these lines:

![img](img1.jpg)
![img](img2.jpg)
![img](img3.jpg)
![img](img4.jpg)
![img](img5.jpg)
![img](img6.jpg)
![img](img7.jpg)
![img](img8.jpg)
![img](img9.jpg)

Repro

See above.

@marchyman marchyman added the bug Something isn't working label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant