-
Notifications
You must be signed in to change notification settings - Fork 99
feat: upgrade tree-sitter from 0.24 to 0.25 #207
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
base: split_parser
Are you sure you want to change the base?
feat: upgrade tree-sitter from 0.24 to 0.25 #207
Conversation
This commit updates the tree-sitter dependency from 0.24 to 0.25, addressing API changes introduced in the newer version. ## Changes - **Cargo.toml**: Update tree-sitter dependency from `0.24` to `0.25` - **bindings/rust/parser.rs**: - Replace deprecated `parse_with()` with `parse_with_options()` - Update API calls to match tree-sitter 0.25 signature - `parse_with_options` now takes 3 args: callback, old_tree, options - Fix lifetime elision warning in `walk()` method ## Testing All existing tests pass with tree-sitter 0.25: - `can_load_block_grammar` - `can_load_inline_grammar` - `markdown_cursor` - `table` - `inline_ranges` ## Breaking Changes None for users of this library. The public API remains unchanged. Internal implementation updated to use newer tree-sitter APIs. ## Benefits - Compatible with latest tree-sitter ecosystem - No more version conflicts for projects using tree-sitter 0.25 - Future-proof for upcoming tree-sitter features
Fixes tree-sitter-grammars#174 ## Problem The `link_destination` node was incorrectly including the angle brackets `<` and `>` when parsing links like `[text](<https://example.com>)`. According to the CommonMark spec, angle brackets are delimiters and should not be part of the link destination itself. ## Solution Modified the grammar in `common/common.js` to wrap the content inside angle brackets with an `alias()`, excluding the brackets from the `link_destination` node range. **Before:** ``` link_destination [0, 10] - [0, 31] # Includes < and > ``` **After:** ``` link_destination [0, 11] - [0, 30] # Excludes < and > ``` ## Changes - `common/common.js`: Wrapped repeated content in `alias()` for angle bracket case - Regenerated parsers with `tree-sitter generate` ## Testing ✅ All existing tests pass ✅ Parser correctly excludes angle brackets from link destination range Co-authored-by: Claude <[email protected]>
|
I've also added a fix for #174 to this PR! Additional Fix: Exclude Angle Brackets from link_destinationThe Fix: Modified grammar to exclude Before: All tests still pass! This PR now includes:
|
Fixes tree-sitter-grammars#206 ## Problem When parsing links with dollar signs in the text, like: `[$NVIM_APPNAME](https://example.com/$VAR)` The parser incorrectly interpreted `$` inside link text as the start of a LaTeX block, preventing the link from being parsed correctly. ## Root Cause The `_inline_base` grammar rule included `$.latex_block`, which was used in ALL inline contexts including inside link text (`_inline_element_no_link`). ## Solution Created a new `_inline_base_no_latex` rule that excludes LaTeX blocks, and modified the dynamic rule generation to use this variant when generating `_inline_element_no_link` rules (used inside link text). **Changes:** - Added `_inline_base_no_latex` rule without `$.latex_block` - Modified line 401 to use appropriate base rule based on context: - Inside links (`link=false`): Use `_inline_base_no_latex` - Outside links (`link=true`): Use `_inline_base` (with LaTeX) ## Testing ✅ All existing tests pass ✅ Links with `$` characters now parse correctly ✅ LaTeX still works outside of link text ## Additional Changes Upgraded to tree-sitter 0.25 to match latest ABI (same as tree-sitter-grammars#207): - Updated Cargo.toml dependencies - Updated parser.rs API calls Co-authored-by: Claude <[email protected]>
|
Thanks for this contribution! What is the status of this PR? I'd love to use this library with the newer version of |
This PR updates the tree-sitter dependency from 0.24 to 0.25, making tree-sitter-md compatible with the latest tree-sitter ecosystem.
Closes #205
Changes
0.24to0.25parse_with()withparse_with_options()walk()methodTesting
✅ All existing tests pass with tree-sitter 0.25:
can_load_block_grammarcan_load_inline_grammarmarkdown_cursortableinline_rangesBreaking Changes
None for library users. The public API remains unchanged. Only internal implementation updated to use newer tree-sitter APIs.
Benefits
Motivation
Many Rust projects (including workspaces) are upgrading to tree-sitter 0.25 and cannot use tree-sitter-md due to native library linking conflicts when both 0.24 and 0.25 are present. This update enables them to use the latest versions.
API Migration Details
The main change is in the
parse_with_optionsmethod signature:tree-sitter 0.24:
tree-sitter 0.25:
This aligns with tree-sitter's move away from timeout-based cancellation in favor of progress callbacks.