feat(preview): CJK-Latin spacing, balanced headings, tabular table digits - #824
Merged
Merged
Conversation
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.
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.
What this is
Three CSS lines for the preview:
text-autospace: normalon.markdown-body, so CJK text gets a small gap next to Latin letters and digits (用Rust写reads as用 Rust 写). Code, kbd, pre and samp keepno-autospaceso monospace alignment is unchanged. Text that already has a space is not spaced twice.text-wrap-style: balanceon headings, so a wrapped heading splits into two even lines instead of leaving one or two characters on the second.font-variant-numeric: tabular-numsin 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-autospaceisno-autospace, so it has to be set explicitly. Engines without support ignore all three.I also tried
text-wrap-style: prettyon 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 check0 errors,npm test1034 pass,npm run test:vitest445 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.