Class StrikethroughExtension

  • All Implemented Interfaces:
    org.commonmark.Extension, org.commonmark.parser.Parser.ParserExtension, org.commonmark.renderer.html.HtmlRenderer.HtmlRendererExtension, org.commonmark.renderer.text.TextContentRenderer.TextContentRendererExtension

    public class StrikethroughExtension
    extends java.lang.Object
    implements org.commonmark.parser.Parser.ParserExtension, org.commonmark.renderer.html.HtmlRenderer.HtmlRendererExtension, org.commonmark.renderer.text.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.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static StrikethroughExtension.Builder builder()  
      static org.commonmark.Extension create()  
      void extend​(org.commonmark.parser.Parser.Builder parserBuilder)  
      void extend​(org.commonmark.renderer.html.HtmlRenderer.Builder rendererBuilder)  
      void extend​(org.commonmark.renderer.text.TextContentRenderer.Builder rendererBuilder)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static org.commonmark.Extension create()
        Returns:
        the extension with default options
      • extend

        public void extend​(org.commonmark.parser.Parser.Builder parserBuilder)
        Specified by:
        extend in interface org.commonmark.parser.Parser.ParserExtension
      • extend

        public void extend​(org.commonmark.renderer.html.HtmlRenderer.Builder rendererBuilder)
        Specified by:
        extend in interface org.commonmark.renderer.html.HtmlRenderer.HtmlRendererExtension
      • extend

        public void extend​(org.commonmark.renderer.text.TextContentRenderer.Builder rendererBuilder)
        Specified by:
        extend in interface org.commonmark.renderer.text.TextContentRenderer.TextContentRendererExtension