fix: prevent LaTeX parsing inside link text #208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes parsing of links with dollar signs in the text or URL.
Fixes #206
Problem
When parsing links with dollar signs, like:
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_basegrammar 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_latexrule that excludes LaTeX blocks, and modified the dynamic rule generation to use this variant when generating_inline_element_no_linkrules (used inside link text).Changes:
_inline_base_no_latexrule without$.latex_blocklink=false→_no_linksuffix): Use_inline_base_no_latexlink=true): Use_inline_base(with LaTeX)Testing
✅ All existing tests pass
✅ Links with
$characters now parse correctly as links✅ LaTeX still works correctly outside of link text
Example
Before: Link not recognized,
$NVIMparsed as LaTeX startAfter: Entire
[$NVIM_APPNAME](...)parsed as a linkAdditional Changes
Also upgraded to tree-sitter 0.25 to match latest ABI:
parse_with→parse_with_options)walk()methodThis keeps the codebase compatible with the latest tree-sitter ecosystem.