Skip to content

Add bracket detection in tokenize_inline to prevent merging adjacent links #175

Description

@coderabbitai

Issue Description

The tokenize_inline function in src/tokenize.rs does not properly handle adjacent links without spaces between them. The current while loop condition on line 105-107 only checks for whitespace and backticks, but should also check for bracket characters to prevent merging adjacent markdown links.

Current Behaviour

Adjacent links like [link1](url1)[link2](url2) may be incorrectly tokenised as a single text token instead of being recognised as separate link tokens.

Proposed Solution

Modify the while loop condition to include bracket detection:

while i < chars.len() 
    && !chars[i].is_whitespace() 
    && chars[i] != '`' 
    && chars[i] != '[' 
    && !(chars[i] == '!' && i + 1 < chars.len() && chars[i + 1] == '[') 
{
    i += 1;
}

Context

  • File: src/tokenize.rs
  • Lines: 105-107
  • Function: tokenize_inline

References

Metadata

Metadata

Assignees

Labels

mediumRoadmap items to schedule within the current quarter. Clear scope, normal review cycles.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions