Skip to content

feat(linter): refactor parser to use remark for AST parsing - #3

Merged
davideast merged 1 commit into
mainfrom
feat/remark-parser
Apr 11, 2026
Merged

feat(linter): refactor parser to use remark for AST parsing#3
davideast merged 1 commit into
mainfrom
feat/remark-parser

Conversation

@davideast

Copy link
Copy Markdown
Collaborator

This pull request refactors the ParserHandler to use remark and the unified ecosystem instead of regular expressions for extracting YAML tokens from Markdown files. This makes the parser spec-compliant and robust against complex formatting and edge cases.

Key Changes

Core Refactor

  • AST Parsing: Replaced string splitting and regex matching with full AST parsing using remark-parse and remark-frontmatter.
  • Unified Pipeline: Implemented a unified processor to parse the document and traverse the tree with unist-util-visit.
  • Robust Extraction: Now correctly handles YAML blocks with attributes (e.g., ```yaml title="theme") and handles indentation correctly as per Markdown specs.

Testing & Verification

  • New Tests: Added a test for code blocks with attributes in handler.test.ts.
  • Adversarial Testing: Added a test for long circular reference chains (10 steps) in model/handler.test.ts during a bug bash session, which passed successfully in 0.09ms.
  • 100% Success: All 115 unit tests and the end-to-end fixture test pass successfully.

Dependencies Added

  • unified
  • remark-parse
  • remark-frontmatter
  • unist-util-visit
  • @types/mdast (dev dependency for type resolution)

@davideast
davideast merged commit baab34c into main Apr 11, 2026
3 checks passed
@davideast
davideast deleted the feat/remark-parser branch April 11, 2026 00:27
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