Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cjk-branch] Tweak CJK handling #557

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,10 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
if (len == -1) {
before_char = 10;
}
if (before_char >= 0xfe00 && before_char <= 0xfe02) {
if ((before_char >> 4) == 0xfe0 && ((before_char >= 0xfe00 && before_char <= 0xfe02) || before_char == 0xfe0e)) {
// standard variation selector, go back one more code point:
// U+FE00..U+FE02: can follow a ideograph
// U+FE0E: forces the previous character to be rendered as not emoji but text (e.g. U+303D, U+3297)
before_char_pos -= 1;
while (peek_at(subj, before_char_pos) >> 6 == 2 &&
before_char_pos > 0) {
Expand Down
7 changes: 4 additions & 3 deletions src/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,16 @@ int cmark_utf8proc_is_CJK(int32_t uc) {
|| (uc >= 0x3040 && uc <= 0x309f) // Hiragana
|| (uc >= 0x30a0 && uc <= 0x30ff) // Katakana
|| (uc >= 0x3100 && uc <= 0x312f) // Bopomofo
|| (uc >= 0x3130 && uc <= 0x318f) // Kanbun
|| (uc >= 0x3130 && uc <= 0x318f) // Hangul Compatibility Jamo
|| (uc >= 0x3190 && uc <= 0x319f) // Kanbun
|| (uc >= 0x31a0 && uc <= 0x31bf) // Bopomofo Extended
|| (uc >= 0x31c0 && uc <= 0x31ef) // CJK Strokes
|| (uc >= 0x31f0 && uc <= 0x31ff) // Katakana Phonetic Extensions
|| (uc >= 0x3200 && uc <= 0x32ff) // Enclosed CJK Letters & Months
|| (uc >= 0x3300 && uc <= 0x33ff) // CJK Compatibility
|| (uc >= 0x3400 && */ uc <= 0x4dbf) // CJK Unified Ideographs Extension A
|| (uc >= 0x4e00 && /* uc <= 0x9fff) // CJK Unified Ideographs
|| (uc >= 0x3400 && uc <= 0x4dbf) // CJK Unified Ideographs Extension A
|| (uc >= 0x4dc0 && uc <= 0x4dff) // Yijing Hexagram Symbols
|| (uc >= 0x4e00 && uc <= 0x9fff) // CJK Unified Ideographs
|| (uc >= 0xa000 && uc <= 0xa48f) // Yi Syllables
|| (uc >= 0xa490 && */ uc <= 0xa4cf) // Yi Radicals
|| (uc >= 0xf900 && uc <= 0xfaff) // CJK Compatibility Ideographs
Expand Down
7 changes: 7 additions & 0 deletions test/cjkemphasis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,10 @@ Git**(注:不是GitHub)**
````````````````````````````````


```````````````````````````````` example
〽︎**(庵点)**は、
.
<p>〽︎<strong>(庵点)</strong>は、</p>
````````````````````````````````