Skip to content

Refactor: Extract code fence utilities and improve parser robustness#50

Closed
leoafarias wants to merge 2 commits intomainfrom
leoafarias/refactor/code-cleanup
Closed

Refactor: Extract code fence utilities and improve parser robustness#50
leoafarias wants to merge 2 commits intomainfrom
leoafarias/refactor/code-cleanup

Conversation

@leoafarias
Copy link
Collaborator

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.

  • New code_fence.dart utility provides parseCodeFenceLine() and canCloseCodeFence() functions used by FencedCodeParser, MarkdownParser, and TagTokenizer
  • Supports both backtick (```) and tilde (~~~) markers with spec-compliant closure semantics
  • FrontmatterParser now validates YAML syntax and rejects non-map payloads (lists/arrays)
  • MarkdownParser slide splitting respects fence boundaries—--- inside code blocks no longer splits
  • TagTokenizer code block detection properly matches marker types and enforces length requirements
  • 22 new unit tests for code_fence utility plus 20+ additional parser tests
  • All 913+ existing tests pass; no behavioral regressions

Commits

  • refactor: extract code fence utilities and improve parser robustness

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

- 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
@docs-page
Copy link

docs-page bot commented Mar 5, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/superdeck~50

Documentation is deployed and generated using docs.page.

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

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

@leoafarias
Copy link
Collaborator Author

Closing per request.

@leoafarias leoafarias closed this Mar 5, 2026
@leoafarias leoafarias deleted the leoafarias/refactor/code-cleanup branch March 5, 2026 19:17
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.

1 participant