Markdown: double underscores inside emphasis can truncate the span
Author: torjan0Created Sep 13, 2026Updated Sep 13, 2026
Prettier 3.9.6
--parser markdown
Input:
*a__b__c*
Output:
_a__b_\_c_
Expected output:
*a__b__c*
Why?
The entire identifier should remain emphasized; equivalent delimiter choices are fine. CommonMark 0.31.2 renders the input as <em>a__b__c</em>, but the output as <em>a__b</em>_c_. The emphasized key__x__value sentence also fails; the corresponding key__xy__value control preserves meaning.
Also reproduced on development commit 891accaaab6dab0fbb5eba6748fbb1f5ac4809b5. Related #3834 concerns word-leading underscores inside strong text; this example uses intraword underscores inside emphasis and introduces an escape despite a correct input AST.
GPT-6 Astra assisted; I manually reviewed this report.
Source: prettier/prettier