Skip to content

Editor: stop scaling heading sizes in the markdown source view - #628

Merged
compscidr merged 1 commit into
mainfrom
fix/editor-heading-sizes
Sep 23, 2026
Merged

compscidr merged 1 commit into
mainfrom
fix/editor-heading-sizes

Conversation

@compscidr

Copy link
Copy Markdown
Collaborator

Noticed while scoping #624: the editor still styles its content as though the browser were the renderer, which #617 moved to the server.

Problem

SimpleMDE's stylesheet scales headings inside the CodeMirror editing surface:

.CodeMirror .CodeMirror-code .cm-header-1 { font-size:200%; line-height:200% }
.CodeMirror .CodeMirror-code .cm-header-2 { font-size:160%; line-height:160% }
.CodeMirror .CodeMirror-code .cm-header-3 { font-size:125%; line-height:125% }
.CodeMirror .CodeMirror-code .cm-header-4 { font-size:110%; line-height:110% }

That was a live preview back when the browser rendered markdown. Now the Preview tab renders through the server, so these sizes are a second rendering that disagrees with the real one — and the line height jumps as soon as you type a #.

Fix

Override the four rules (plus 5 and 6 for completeness) in www/css/admin.css, which already owns the .editor-tabs / .editor-preview-pane chrome from #617 and is loaded after the SimpleMDE CDN stylesheet in _head.html, so an equal-specificity rule wins on source order.

SimpleMDE stays. It is what provides paste/drag image upload (via inline-attachment) and the bold/italic/link toolbar; this only removes its stylesheet's preview pretensions.

Verified

Measured computed styles in Chrome against a real SimpleMDE 1.11.2 instance, two otherwise-identical pages differing only by this override:

h1 h2 h3 body
stock 32px 25.6px 20px 16px
with override 16px 16px 16px 16px

font-weight:700 on headings, cm-strong, cm-em and the cm-comment code background are all unchanged.

Note

This lands in goblog rather than the themes because themes do not ship admin.css — every theme picks it up with no theme release.

🤖 Generated with Claude Code

SimpleMDE's stylesheet scales headings inside the CodeMirror editing
surface to 200%/160%/125%/110%, a leftover from when the browser was
also the renderer. #617 moved rendering to the server, so those sizes
now only claim to show the result while disagreeing with it, and the
line height lurches as you type past a "#".

Override them in admin.css, which already owns the editor chrome added
by #617 and loads after the SimpleMDE CDN stylesheet, so an
equal-specificity rule wins on source order. Measured in Chrome against
SimpleMDE 1.11.2: headings go from 32/25.6/20px to 16px, matching the
body text, while font-weight:700, cm-strong, cm-em and the code
background are left alone.

This lives in goblog rather than the themes because themes do not ship
admin.css, so every theme picks it up without a release.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 23, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change is a targeted CSS override loaded after SimpleMDE, and it addresses the described UX issue without affecting the server-rendered preview path.

Review effort: Lite
Findings: None

What changed in this PR

Adjusts the admin editor’s Markdown source view styling so CodeMirror headings don’t visually “render” as oversized headings, aligning the typing experience with the server-rendered Preview introduced by #617.

Changes:

  • Override SimpleMDE/CodeMirror .cm-header-1 through .cm-header-6 rules in admin.css to remove heading font-size scaling.
  • Normalize heading line-height in the editing surface to prevent line-height jumps while typing headings.
File Description
www/​css/​admin.css Overrides SimpleMDE CodeMirror heading styles so the editor source view no longer scales heading sizes/line-height.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@compscidr
compscidr merged commit bb64b2f into main Sep 23, 2026
3 of 4 checks passed
@compscidr
compscidr deleted the fix/editor-heading-sizes branch September 23, 2026 07:07
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