Skip to content

Enhance CJK rendering - #404

Open
LFRon wants to merge 3 commits into
github:masterfrom
LFRon:master
Open

LFRon wants to merge 3 commits into
github:masterfrom
LFRon:master

Conversation

@LFRon

@LFRon LFRon commented Nov 26, 2026

Copy link
Copy Markdown

Add additional CJK font rendering for MarkDown

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.
Copilot AI adaptive review requested due to automatic review settings November 26, 2026 12:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 thread src/inlines.c
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;
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.

2 participants