Hide YAML frontmatter in markdown preview - #139
Merged
mattenarle10 merged 3 commits intoAug 17, 2026
Merged
Conversation
OliverBennettdev
marked this pull request as ready for review
August 16, 2026 03:37
Owner
|
The implementation matches #134 and the regression coverage looks focused, including source-line preservation, CRLF handling, mid-document thematic breaks, and unterminated frontmatter. I do not see any GitHub CI checks reported for this branch yet, so please enable/run the repository checks before merge. Once CI is green, this can close #134. |
Owner
|
Thanks for the focused fix and regression tests. The frontmatter masking preserves source-line mapping and keeps regular thematic breaks working, which is exactly what the preview needed. Merged, and #134 is now closed. |
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
Root cause
src/lib/markdown.tspassed the source directly to markdown-it. Without a frontmatter rule, the opening---was rendered as a thematic break and the closing---could turn the metadata above it into a setext heading.Implementation
This uses a small dependency-free
maskYamlFrontmatterhelper. It replaces only non-newline characters in a leading, closed---block with spaces before markdown parsing. That hides the metadata while preserving both line and character positions, so the existingdata-sline/data-elinemapping remains aligned with the original source.The masked source is also used for fenced-language discovery, so metadata cannot trigger unnecessary syntax-highlighter loading.
Validation
tests/markdown.test.tsCloses #134