Repository navigation
Conversation
Add a Unicode-range classifier for CJK characters used by the cjk-friendly emphasis rules. The ranges follow the markdown-cjk-friendly specification and Comrak's port so both parsers agree on which code points can act as CJK boundaries, including Hangul, kana, ideographs, CJK punctuation, and extension planes.
CJK text and CJK punctuation now count as flanking boundaries for emphasis, strong emphasis, and the extension delimiter scanner used by strikethrough. Handle variation selectors by looking through to the preceding CJK base character, and recognise the fullwidth-colon label closer used by MarkText. This makes cases such as 例子**"加粗"**例子 and **来源:**2013年 parse correctly without changing non-CJK CommonMark behaviour.
Cover the MarkText/Comrak CJK cases for strong, emphasis, underscores, and strikethrough, plus the non-regression cases for non-flanking delimiters. Wire the fixture into ctest so a future change cannot silently drop CJK support.
There was a problem hiding this comment.
🟡 Changes recommended
The CJK delimiter change also affects smart quotes, causing an opening quote next to CJK punctuation to render as a closing quote under --smart.
1 open issue
What changed in this PR
This PR improves CJK Markdown rendering by adjusting delimiter rules for emphasis and strikethrough around CJK text and punctuation.
Changes:
- Add CJK character classification and variation-selector handling.
- Update delimiter flanking rules for CJK boundaries.
- Add rendering examples and register them with the test suite.
| File | Description |
|---|---|
test/CMakeLists.txt |
Registers the CJK rendering tests with strikethrough enabled. |
test/cjk_emphasis.txt |
Adds CJK emphasis, strikethrough, and non-regression examples. |
src/utf8.h |
Declares the CJK classification helper. |
src/utf8.c |
Implements CJK Unicode range classification. |
src/inlines.c |
Adjusts delimiter scanning for CJK boundaries and variation selectors. |
Review effort: Balanced (adaptive)
Comment on lines
+500
to
+501
| bool before_cjk = is_cjk_before(subj, before_char_pos, before_char); | ||
| bool after_cjk = cmark_utf8proc_is_cjk(after_char) != 0; |
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.

Add additional CJK font rendering for MarkDown