Refactor: Extract code fence utilities and improve parser robustness#50
Closed
leoafarias wants to merge 2 commits intomainfrom
Closed
Refactor: Extract code fence utilities and improve parser robustness#50leoafarias wants to merge 2 commits intomainfrom
leoafarias wants to merge 2 commits intomainfrom
Conversation
- Extract parseCodeFenceLine() and canCloseCodeFence() into shared code_fence.dart utility to eliminate duplication across FencedCodeParser, MarkdownParser, and TagTokenizer - Implement line-by-line fence detection to properly support both backtick and tilde markers with spec-compliant closure semantics (same marker type, length >= opening) - Upgrade FrontmatterParser to validate YAML syntax and enforce map-only payloads (reject lists/arrays) - Enhance MarkdownParser slide splitting with fence-aware state machine to protect --- delimiters inside code blocks - Improve TagTokenizer code block detection with proper marker matching and length validation - Add dedicated unit tests for new code_fence utility (22 tests covering boundaries, markers, and edge cases) - Add 20+ new test cases across parsers validating tilde support, fence closure rules, and malformed YAML rejection - Remove redundant type annotations on Logger and RegExp initializations - All 913+ existing tests pass; no behavioral regression in preserved test cases
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
|
Visit the preview URL for this PR (updated for commit bedb879): https://superdeck-dev--pr50-leoafarias-refactor-uf27p8x6.web.app (expires Sat, 04 Apr 2026 18:54:04 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bd68fc230762285849207e7e120aaf87cd4ca2f9 |
Collaborator
Author
|
Closing per request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Extracted code fence parsing logic into a shared utility module to eliminate duplication and improve consistency across parsers. Upgraded frontmatter validation and enhanced slide splitting with proper fence-aware state machines.
code_fence.dartutility providesparseCodeFenceLine()andcanCloseCodeFence()functions used by FencedCodeParser, MarkdownParser, and TagTokenizer---inside code blocks no longer splitsCommits
Test Plan
✓
melos run test— 913+ tests passing across core and builder packages✓ New code_fence_test.dart validates fence detection edge cases
✓ Enhanced parser tests cover tilde support, fence closure rules, malformed YAML rejection