What Happened
While writing a blog post, I noticed broken rendering:
ホルムズ海峡は世界の海上石油輸送の**20〜25%**が通過する。
The ** markers were displayed as plain text instead of rendering bold.
Adding spaces around the markers fixed it — but inserting spaces in Japanese text is unnatural. This was a bug.
Root Cause
The scanDelims function in markdown-it-py.
In the CommonMark spec, ** must be a right-flanking delimiter to close bold. The check:
right_flanking = not (isLastPunctChar and not (isNextWhiteSpace or isNextPunctChar))
For the closing ** in **46%**を:
lastChar='%'→ punctuation →isLastPunctChar=TruenextChar='を'→ CJK character → neither whitespace nor punctuation
Result: right_flanking = False. The closing ** is rejected.
CJK characters after ASCII punctuation break bold rendering. This affects Japanese, Chinese, and Korean text.
The Fix
6 lines added to scanDelims in state_inline.py. Treat CJK characters (U+2E80+) as punctuation so they are recognized as word boundaries:
# Treat CJK ideographs as punctuation for flanking delimiter checks
if not isNextPunctChar and ord(nextChar) > 0x2E7F:
isNextPunctChar = True
if not isLastPunctChar and ord(lastChar) > 0x2E7F:
isLastPunctChar = True
Test results:
| Input | Before | After |
|---|---|---|
湾岸の**46%**を供給 |
** remains as text | 46% renders bold |
の**20〜25%**が通過する |
** remains as text | 20〜25% renders bold |
日本語の**太字**テスト |
works | works |
English **bold** test |
works | works |
No impact on English-only text.
What Claude Code Did
From bug discovery to PR submission — I never looked at or read the code myself.
- Found the bug — noticed broken rendering in blog build output, instructed Claude
- Identified the cause — read markdown-it-py source, analyzed
scanDelimsflanking delimiter logic - Directed the fix — Claude initially suggested creating a patch script, but I instructed it to fix the package directly. Claude created the 6-line fix treating CJK characters as punctuation
- Tested — 8 test patterns in both Japanese and English
- Created a fork —
aiseed-dev/markdown-it-pywithfix/cjk-emphasisbranch - Submitted a PR — executablebooks/markdown-it-py#387
- Updated the project — switched
requirements.txtto the fork, rebuilt all pages
No Need to Outsource
Traditionally, this kind of work would require:
- Filing a bug report and commissioning investigation
- External library research and fix strategy review
- Fork management and PR creation
- Test creation and execution
Outsourcing this would cost days to weeks, plus the expense.
I found a bug while writing a blog post, instructed Claude Code, and it did exactly what outsourcing to a contractor would have done.
There is no longer any need to outsource to contractors.
All you need is the ability to describe the problem accurately and judge the results. The ability to read and write code is no longer required on the human side.