Skip to content

Commit 26bb331

Browse files
committed
Fix CJK emphasis delimiter detection in scanDelims
Treat CJK ideographs (codepoints > 0x2E7F) as punctuation in flanking delimiter checks so that emphasis markers work correctly in mixed CJK/ASCII contexts (e.g. 湾岸の**46%**を now renders bold correctly). https://claude.ai/code/session_01RzF12DUuSS8R6Zw1NKwv9o
1 parent 8933147 commit 26bb331

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

markdown_it/rules_inline/state_inline.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def scanDelims(self, start: int, canSplitWord: bool) -> Scanned:
148148
isLastWhiteSpace = isWhiteSpace(ord(lastChar))
149149
isNextWhiteSpace = isWhiteSpace(ord(nextChar))
150150

151+
# Treat CJK ideographs as punctuation for flanking delimiter checks
152+
# so that emphasis works correctly in mixed CJK/ASCII contexts.
153+
# e.g. 湾岸の**46%**を should render <strong>46%</strong>
154+
if not isNextPunctChar and ord(nextChar) > 0x2E7F:
155+
isNextPunctChar = True
156+
if not isLastPunctChar and ord(lastChar) > 0x2E7F:
157+
isLastPunctChar = True
158+
151159
left_flanking = not (
152160
isNextWhiteSpace
153161
or (isNextPunctChar and not (isLastWhiteSpace or isLastPunctChar))

0 commit comments

Comments
 (0)