Headings sizes inconsistency

@horacio this has been happening for long time but I didn't tell you. Related to the user control of the font style, it happens to me a lot that I want header on the same size but even if they are, they look different.

I guess it has to be with change of block but this is unexpected behaviour.


See example

Solution

Headings with the same explicit text size (Small/Medium/Big) now render at the same size at every nesting depth. The CSS change in frontend/packages/ui/src/hm-prose.css measures explicit heading sizes from the top-level heading size, retaining the existing ratios and top-level appearance. Headings without explicit sizes and paragraph sizes are unchanged. A Playwright regression test and headingSizes harness fixture were added.

Root cause: Inline [data-text-size] rules used 0.875/1/1.25em relative to the heading's own font size, which decreases with nesting depth (h2 1.55em, h3 1.3em, h4 1.15em). Consequently, Small rendered at 24.4px, 20.5px and 18.1px at successive depths.

Verification reported by T3: The three new regression cases failed on unmodified code on repeated runs, including on rebased origin/main with the fix stashed; all three passed with the fix. Final editor Playwright suite: 139/139 passed. Root pnpm typecheck, pnpm format:check, and node scripts/check-ts-directives.mjs passed. An earlier suite run had one math-block selection failure; that test file passed 60/60 in isolation both with and without this change, and the final full suite passed. Screenshots were captured with Playwright Chromium against the editor harness. Local agent-ci was not run (no Docker); Electron desktop was not checked visually.

Scope caveat: Choosing Medium in the Size menu removes the explicit size rather than storing medium, so those headings still shrink with depth. The fix applies to explicit Small/Big and imported explicit Medium values.

Before / After

Before: headings with the same explicit size differ by nesting depth.

Before — Unmodified code: h2/h3/h4 headings with the same explicit size render at different sizes (small 24.4/20.5/18.1px, medium 27.9/23.4/20.7px, big 34.9/29.3/25.9px).

After: headings with the same explicit size match at every depth.

After — With the fix: same headings render identically at every depth (small 24.4px, medium 27.9px, big 34.9px); top-level sizes unchanged.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime