Class StrikethroughExtension

java.lang.Object
org.commonmark.ext.gfm.strikethrough.StrikethroughExtension
All Implemented Interfaces:
Extension, Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension, MarkdownRenderer.MarkdownRendererExtension, TextContentRenderer.TextContentRendererExtension

Extension for GFM strikethrough using ~ or ~~ (GitHub Flavored Markdown).

Example input:

~foo~ or ~~bar~~

Example output (HTML):

<del>foo</del> or <del>bar</del>

Create the extension with create() and then add it to the parser and renderer builders (Parser.Builder.extensions(Iterable), HtmlRenderer.Builder.extensions(Iterable)).

The parsed strikethrough text regions are turned into Strikethrough nodes.

If you have another extension that only uses a single tilde (~) syntax, you will have to configure this StrikethroughExtension to only accept the double tilde syntax, like this:

     
     StrikethroughExtension.builder().requireTwoTildes(true).build();
     
 

If you don't do that, there's a conflict between the two extensions and you will get an IllegalArgumentException when constructing the parser.