Skip to content

feat(preview): CJK-Latin spacing, balanced headings, tabular table digits - #824

Merged
PathGao merged 2 commits into
masterfrom
feat/preview-text-wrap-autospace
Sep 22, 2026
Merged

PathGao merged 2 commits into
masterfrom
feat/preview-text-wrap-autospace

Conversation

@PathGao

@PathGao PathGao commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

What this is

Three CSS lines for the preview:

  • text-autospace: normal on .markdown-body, so CJK text gets a small gap next to Latin letters and digits (用Rust写 reads as 用 Rust 写). Code, kbd, pre and samp keep no-autospace so monospace alignment is unchanged. Text that already has a space is not spaced twice.
  • text-wrap-style: balance on headings, so a wrapped heading splits into two even lines instead of leaving one or two characters on the second.
  • font-variant-numeric: tabular-nums in table cells, so digits in a column line up with fonts whose default numerals are proportional. The default system fonts are already tabular, so this only shows with a custom preview font.

The initial value of text-autospace is no-autospace, so it has to be set explicitly. Engines without support ignore all three.

I also tried text-wrap-style: pretty on paragraphs and dropped it: in WebKit it shortens every line of a CJK paragraph by about two characters to lengthen the last one.

Verification

macOS 27, debug build next to the current release on the same document. The spacing and heading changes are visible; inline code and code blocks are the same width as before. In a WKWebView, 中文abc中文 measures 94.2px with autospace and 90.2px without.

npm run check 0 errors, npm test 1034 pass, npm run test:vitest 445 pass.

Not run on Windows or Linux. Support there comes from browser-compat-data: WebView2 has all three (Chromium 140+ for autospace), WebKitGTK depends on the distro version.

PathGao added 2 commits September 23, 2026 05:20
text-autospace: normal on .markdown-body. Code keeps no-autospace so
monospace alignment is unchanged. Engines without support ignore it.
text-wrap-style: balance on headings so a wrapped heading does not end
on one or two characters. tabular-nums in table cells so numbers in a
column line up.
@PathGao
PathGao merged commit a9a8d7b into master Sep 22, 2026
4 checks passed
@PathGao
PathGao deleted the feat/preview-text-wrap-autospace branch September 22, 2026 21:36
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