tree-sitter-grammars / tree-sitter-markdown

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

Error on markdown images #18

Closed shadmansaleh closed 2 years ago

shadmansaleh commented 2 years ago

If two consecutive lines have images the parser fails.

Example

### test doc

![img1](link1)
![img2](link2)

what's going on?
### why an error after two image links ?

ast from TSPlayground

atx_heading [0, 0] - [1, 0]
  atx_h3_marker [0, 0] - [0, 3]
  heading_content [0, 3] - [0, 12]
ERROR [2, 0] - [7, 0]
  image [3, 0] - [3, 14]
    image_description [3, 2] - [3, 6]
    link_destination [3, 8] - [3, 13]
  ERROR [4, 0] - [5, 0]
  ERROR [6, 0] - [6, 3]

But if new_line between the images is removed or additional line is added between the two images the parser works .

Means this works but the above one doesn't

![img1](link1)![img2](link2)

![img1](link1)

![img2](link2)
shadmansaleh commented 2 years ago

Thanks for the quick patch . By the way do you know how to update the parser to master ? TSUpdate doesn't seem to want to make an update happen ;]

MDeiml commented 2 years ago

Hm, it works for me. You could always just try to :TSUninstall and install again...

clason commented 2 years ago

The parsers are locked in nvim-treesitter; there's an automated CI action that bumps the versions: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/.github/workflows/update-parsers-pr.yml

So you'll have to wait until that picks up the updates to this parser (nvim-treesitter master gets a push) and gets merged. ~Alternative is :TSInstallFromGrammar, which also pulls the tip of the repo, I believe.~ EDIT Nope; best way is to clone the repo and use the local copy as a new parser source.

MDeiml commented 2 years ago

Oh I didn't know thank you.

clason commented 2 years ago

Or, probably easiest, just edit the lockfile.json locally and remove the revision key; that should make it TSInstall from the corresponding master.

shadmansaleh commented 2 years ago

@clason thanks for the info. But what's the purpose of the lock? The CI updates the lockfile with commit id from master I can't see why update can't directly happen from master . If ref is set to specific tag/commit then the lock makes sense but when the ref is master does the lock add any benefit ?

clason commented 2 years ago

The ref is indeed set to a specific commit, but only if nvim-treesitter CI passes; otherwise the revision is not updated. This ensures that nvim-treesitter never installs a (known) broken parser.

shadmansaleh commented 2 years ago

Thanks now that makes sense :)

theHamsta commented 2 years ago

And we know that our queries are still compatible. The queries have to be always up-to-date with the parser when the grammar changes.