Skip to content

editor: fix frontmatter heading styling#426

Open
junereycasuga wants to merge 1 commit into
ZenNotes:mainfrom
junereycasuga:fix/frontmatter-render
Open

editor: fix frontmatter heading styling#426
junereycasuga wants to merge 1 commit into
ZenNotes:mainfrom
junereycasuga:fix/frontmatter-render

Conversation

@junereycasuga

Copy link
Copy Markdown
Contributor

DISCLAIMER: I'm not sure if this is the intended UI or not. But creating a PR anyway :)

Fix frontmatter styling in the editor.

CodeMirror can tokenize the line before a closing --- frontmatter fence as a setext heading when there isn't a blank line before the fence. This caused valid frontmatter to render with large heading typography in edit mode.

This makes frontmatter card styling override heading tokens inside the frontmatter block, so both forms render consistently.

Also adds a preview regression test that verifies leading YAML/TOML frontmatter is hidden from rendered markdown.

Before:
image

After:
image

@junereycasuga
junereycasuga requested a review from adibhanna as a code owner July 19, 2026 05:29
adibhanna added a commit that referenced this pull request Jul 20, 2026
Frontmatter whose last line abuts the closing `---` (no blank line before the
fence) gets tokenized as a setext heading by CodeMirror's markdown parser, so
it rendered with large heading typography in edit mode. The metadata card owns
frontmatter presentation, so neutralize heading tokens (color + font/weight/
line-height/spacing) inside `.cm-frontmatter-line`. Also adds a preview
regression test that leading YAML/TOML frontmatter stays hidden.

Verified in the app: the setext-tokenized frontmatter line renders at normal
card size while a real body heading stays large.

Thanks to @junereycasuga for the fix.
@adibhanna

Copy link
Copy Markdown
Contributor

Thanks @junereycasuga — this is exactly right, and yes, it's the intended UI: leading frontmatter is meant to render as a compact metadata card, never as body-heading typography.

Nice diagnosis on the setext-heading tokenization (a frontmatter line abutting the closing --- with no blank line in between). I verified it in the running app: with the fix, that setext-tokenized line renders at normal card size while a real body # Heading below it stays large. CI is green and the preview regression test passes.

Merged into the v2.15.0 release branch in 9ab0424 (this repo lands fixes on a per-release branch that fast-forwards into main at release, so it'll ship in 2.15.0). Retargeting this PR's base to that branch to reflect the merge.

@adibhanna

Copy link
Copy Markdown
Contributor

Small correction: I couldn't retarget the base — GitHub reports "no new commits between v2.15.0 and fix/frontmatter-render" because your commit is already contained in the release branch (I brought it in via a merge, 9ab0424, so your authorship is preserved). I'll leave this PR open against main; it'll flip to Merged automatically once v2.15.0 fast-forwards into main at release. Nothing further needed on your end — thanks again!

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