commonmark / commonmark-java

Java library for parsing and rendering CommonMark (Markdown)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single-tilde strikethrough not recognized by org.commonmark.ext.gfm.strikethrough extension

davidkwlam opened this issue · comments

Steps to reproduce the problem (provide example Markdown if applicable):

This is a GFM ~strikethrough~

Expected behavior:

<p>This is a GFM <del>strikethrough</del></p>

Actual behavior:

<p>This is a GFM ~strikethrough~</p>

Notes:

This works fine with double tilde: This is a GFM ~~strikethrough~~ is correctly parsed to <p>This is a GFM <del>strikethrough</del></p>. I'm passing a StrikethroughExtension instance to both the parser and html renderer.

GitHub flavoured markdown supports both double and single tilde strikethrough:

~single tilde strikethrough~: single tilde strikethrough
~~double tilde strikethrough~~: double tilde strikethrough

Thank you for all your hard work!

Hi, you're right. Looks like GitHub only recently (August 2022) changed the wording in their spec, from:

Strikethrough text is any text wrapped in two tildes (~).

To:

Strikethrough text is any text wrapped in a matching pair of one or two tildes (~).

That's a bit annoying. I would normally be hesitant to change behavior of syntax like this now, but given that the aim of the extension is to be compatible with GitHub, I think we should do it anyway. Hopefully no one relies on the previous behavior of single tildes. If they do we can make the behavior configurable via an option later.