Conversation
| /* make long words/inline code not x overflow */ | ||
| main { | ||
| overflow-wrap: break-word; | ||
| text-autospace: normal; |
There was a problem hiding this comment.
Looks reasonable.
Does it matter that caniuse shows its usage rate is only 77%?
There was a problem hiding this comment.
For those non-CJK users, it is kinda a best practice among programmers that you insert space between CJK and other ASCII characters for readability. See https://github.com/sparanoid/chinese-copywriting-guidelines. And there is a well-known plugin for this behavior: https://github.com/vinta/pangu.js.
There was a problem hiding this comment.
I guess the reason for the low rate is the common usage of old Chrome. I'm not sure to what extent does mdbook want to maintain compatibility.
And for pangu, I think text-autospace is just a browser built-in solution for it? I remember that pangu has some visual issues since it scans all text and insert whitespaces at runtime.
The CSS property
text-autospacehas finally work for all mainstream browsers (you can see this news in the top banner of the MDN documentation). This property will automatically insert spaces between CJK and non-CJK characters and around punctuation, which is the preferred approach for CJK typesettings (This typesetting rule is adopted in the Chinese version of "The Rust Programming Language", where all spaces are manually inserted).Before applying this property:
After applying this property:
The property will only add spaces if there is no space, and if the author has manually inserted spaces, there will be no difference.