Skip to content

Conversation

@ekropotin
Copy link
Owner

Fixed bug where MD051 incorrectly flagged text patterns like "- [notalink] a (#491)" as invalid link fragments. The rule was manually parsing bracket/parenthesis patterns without properly validating markdown link structure.

Changes:

  • Replace manual AST parsing with hybrid approach using tree-sitter "link" nodes + regex
  • Add proper validation to ensure only valid markdown links text are processed
  • Consolidate duplicate regex patterns into shared MARKDOWN_LINK_PATTERN for efficiency
  • Add comprehensive documentation explaining why tree-sitter alone isn't sufficient
  • Add test case for the specific bug scenario to prevent regression

The fix ensures MD051 only processes legitimate markdown links while maintaining detection of all valid link fragment violations.

🤖 Generated with Claude Code

Fixed bug where MD051 incorrectly flagged text patterns like "- [notalink] a (#491)"
as invalid link fragments. The rule was manually parsing bracket/parenthesis patterns
without properly validating markdown link structure.

Changes:
- Replace manual AST parsing with hybrid approach using tree-sitter "link" nodes + regex
- Add proper validation to ensure only valid markdown links [text](url) are processed
- Consolidate duplicate regex patterns into shared MARKDOWN_LINK_PATTERN for efficiency
- Add comprehensive documentation explaining why tree-sitter alone isn't sufficient
- Add test case for the specific bug scenario to prevent regression

The fix ensures MD051 only processes legitimate markdown links while maintaining
detection of all valid link fragment violations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ekropotin ekropotin merged commit cfae6bd into main Sep 7, 2025
4 checks passed
@ekropotin ekropotin deleted the dev branch September 7, 2025 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants