Skip to content

Commit

Permalink
Make left/right flankingness depend on CJK characters.
Browse files Browse the repository at this point in the history
If either the character before or the character after is CJK
the delimiter run is counted as both left- and right-flanking.

The intent is to better support emphasis in languages that
do not use spaces. See #650.
  • Loading branch information
jgm committed May 7, 2024
1 parent 5c703f4 commit 2d825d0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,17 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
after_char = 10;
}
left_flanking = numdelims > 0 && !cmark_utf8proc_is_space(after_char) &&
(!cmark_utf8proc_is_punctuation_or_symbol(after_char) ||
((!cmark_utf8proc_is_punctuation_or_symbol(after_char) ||
cmark_utf8proc_is_space(before_char) ||
cmark_utf8proc_is_punctuation_or_symbol(before_char));
cmark_utf8proc_is_punctuation_or_symbol(before_char)) ||
(cmark_utf8proc_is_CJK(before_char) ||
cmark_utf8proc_is_CJK(after_char)));
right_flanking = numdelims > 0 && !cmark_utf8proc_is_space(before_char) &&
(!cmark_utf8proc_is_punctuation_or_symbol(before_char) ||
cmark_utf8proc_is_space(after_char) ||
cmark_utf8proc_is_punctuation_or_symbol(after_char));
((!cmark_utf8proc_is_punctuation_or_symbol(before_char)
|| cmark_utf8proc_is_space(after_char) ||
cmark_utf8proc_is_punctuation_or_symbol(after_char)) ||
(cmark_utf8proc_is_CJK(before_char) ||
cmark_utf8proc_is_CJK(after_char)));
if (c == '_') {
*can_open = left_flanking &&
(!right_flanking ||
Expand Down

0 comments on commit 2d825d0

Please sign in to comment.