cmark-gfm icon indicating copy to clipboard operation
cmark-gfm copied to clipboard

Inconsistent strikethrough behavior with different nesting orders of markup

Open Xuanghdu opened this issue 11 months ago • 1 comments

When combining strikethrough (~~) with other markup, the behavior differs depending on the nesting order.

  • When strikethrough is nested inside, strikethrough renders correctly:

    • **~~a~~**b renders as **~~a~~**b
    • <b>~~a~~</b>b renders as ~~a~~b
  • When strikethrough wraps other markup, no strikethrough is produced:

    • ~~**a**~~b renders as ~~a~~b
    • ~~<b>a</b>~~b renders as ~~a~~b

However, adding a space after makes it work:

  • ~~**a**~~ b renders as ~~a~~ b
  • ~~<b>a</b>~~ b renders as ~~a~~ b

This inconsistency seems unexpected, as the only difference is whether strikethrough is the outer or inner markup.

Would it be possible to:

  1. Confirm if this different behavior based on nesting order is intended
  2. If not intended, make the behavior consistent
  3. If intended, document this behavior in the GFM spec

Xuanghdu avatar Dec 28 '24 02:12 Xuanghdu

To me it is surprising that **~~a~~**b renders as **~~a~~**b because it doesn't work for other inline elements like **_a_**b which renders like **a**b.

It seems like it should render like **~~a~~**b. The reason the underscores render like that is because of CommonMark spec's flanking rules

UziTech avatar Dec 28 '24 03:12 UziTech