Class MarkdownDefaultDecorator

  • All Implemented Interfaces:
    IMarkdownDecorator

    public class MarkdownDefaultDecorator
    extends Object
    implements IMarkdownDecorator
    Default Decorator implementation.

    Example for a user Decorator having a class attribute on <p> tags.

     public class MyDecorator extends DefaultDecorator
     {
         @Override
         public void openParagraph(StringBuilder out)
         {
             out.append("<p class=\"myclass\">");
         }
     }
     
     
    Author:
    René Jeschke <rene_jeschke@yahoo.de>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendHorizontalRuler​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a horizontal ruler is encountered.
      HCImg appendImage​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an image is opened.
      void closeBlockquote​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a blockquote is closed.
      void closeCodeBlock​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a code block is closed.
      void closeCodeSpan​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a code span is closed.
      void closeEmphasis​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an emphasis span is closed.
      void closeHeadline​(com.helger.html.markdown.MarkdownHCStack out, int level)
      Called when a headline is closed.
      void closeLink​(com.helger.html.markdown.MarkdownHCStack out)  
      void closeListItem​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a list item is closed.
      void closeOrderedList​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an ordered list is closed.
      void closeParagraph​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a paragraph is closed.
      void closeStrike​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a strike span is closed.
      void closeStrong​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a strong span is closed.
      void closeSuper​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a superscript span is closed.
      void closeUnorderedList​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an unordered list is closed.
      void openBlockquote​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a blockquote is opened.
      void openCodeBlock​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a code block is opened.
      HCCode openCodeSpan​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a code span is opened.
      void openEmphasis​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an emphasis span is opened.
      IHCElementWithChildren<?> openHeadline​(com.helger.html.markdown.MarkdownHCStack out, int level)
      Called when a headline is opened.
      HCA openLink​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a link is opened.
      HCLI openListItem​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a list item is opened.
      void openOrderedList​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an ordered list is opened.
      void openParagraph​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a paragraph is opened.
      void openStrike​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a strike span is opened.
      void openStrong​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a strong span is opened.
      void openSuper​(com.helger.html.markdown.MarkdownHCStack out)
      Called when a superscript span is opened.
      void openUnorderedList​(com.helger.html.markdown.MarkdownHCStack out)
      Called when an unordered list is opened.
    • Constructor Detail

      • MarkdownDefaultDecorator

        public MarkdownDefaultDecorator()
    • Method Detail

      • openParagraph

        public void openParagraph​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a paragraph is opened.

        Default implementation is:

         out.append("<p>");
         
        Specified by:
        openParagraph in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeParagraph

        public void closeParagraph​(@Nonnull
                                   com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a paragraph is closed.

        Default implementation is:

         out.append("</p>\n");
         
        Specified by:
        closeParagraph in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openBlockquote

        public void openBlockquote​(@Nonnull
                                   com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a blockquote is opened. Default implementation is:
         out.append("<blockquote>");
         
        Specified by:
        openBlockquote in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeBlockquote

        public void closeBlockquote​(@Nonnull
                                    com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a blockquote is closed.

        Default implementation is:

         out.append("</blockquote>\n");
         
        Specified by:
        closeBlockquote in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openCodeBlock

        public void openCodeBlock​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a code block is opened.

        Default implementation is:

         out.append("<pre><code>");
         
        Specified by:
        openCodeBlock in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeCodeBlock

        public void closeCodeBlock​(@Nonnull
                                   com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a code block is closed.

        Default implementation is:

         out.append("</code></pre>\n");
         
        Specified by:
        closeCodeBlock in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openCodeSpan

        @Nonnull
        public HCCode openCodeSpan​(@Nonnull
                                   com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a code span is opened.

        Default implementation is:

         out.append("<code>");
         
        Specified by:
        openCodeSpan in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
        Returns:
        code element
      • closeCodeSpan

        public void closeCodeSpan​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a code span is closed.

        Default implementation is:

         out.append("</code>");
         
        Specified by:
        closeCodeSpan in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openHeadline

        @Nonnull
        public IHCElementWithChildren<?> openHeadline​(@Nonnull
                                                      com.helger.html.markdown.MarkdownHCStack out,
                                                      int level)
        Description copied from interface: IMarkdownDecorator
        Called when a headline is opened.

        Note: Don't close the HTML tag!

        Default implementation is:

          out.append("<h");
         out.append(level);
         
        Specified by:
        openHeadline in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
        level - Headline level
        Returns:
        Headline element
      • closeHeadline

        public void closeHeadline​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out,
                                  int level)
        Description copied from interface: IMarkdownDecorator
        Called when a headline is closed.

        Default implementation is:

          out.append("</h");
         out.append(level);
         out.append(">\n");
         
        Specified by:
        closeHeadline in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
        level - Headline level
      • openStrong

        public void openStrong​(@Nonnull
                               com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a strong span is opened.

        Default implementation is:

         out.append("<strong>");
         
        Specified by:
        openStrong in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeStrong

        public void closeStrong​(@Nonnull
                                com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a strong span is closed.

        Default implementation is:

         out.append("</strong>");
         
        Specified by:
        closeStrong in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openStrike

        public void openStrike​(@Nonnull
                               com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a strike span is opened.

        Default implementation is:

         out.append("<s>");
         
        Specified by:
        openStrike in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeStrike

        public void closeStrike​(@Nonnull
                                com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a strike span is closed.

        Default implementation is:

         out.append("</s>");
         
        Specified by:
        closeStrike in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openEmphasis

        public void openEmphasis​(@Nonnull
                                 com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an emphasis span is opened.

        Default implementation is:

         out.append("<em>");
         
        Specified by:
        openEmphasis in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeEmphasis

        public void closeEmphasis​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an emphasis span is closed.

        Default implementation is:

         out.append("</em>");
         
        Specified by:
        closeEmphasis in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openSuper

        public void openSuper​(@Nonnull
                              com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a superscript span is opened.

        Default implementation is:

         out.append("<sup>");
         
        Specified by:
        openSuper in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeSuper

        public void closeSuper​(@Nonnull
                               com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a superscript span is closed.

        Default implementation is:

         out.append("</sup>");
         
        Specified by:
        closeSuper in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openOrderedList

        public void openOrderedList​(@Nonnull
                                    com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an ordered list is opened.

        Default implementation is:

         out.append("<ol>\n");
         
        Specified by:
        openOrderedList in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeOrderedList

        public void closeOrderedList​(@Nonnull
                                     com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an ordered list is closed.

        Default implementation is:

         out.append("</ol>\n");
         
        Specified by:
        closeOrderedList in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openUnorderedList

        public void openUnorderedList​(@Nonnull
                                      com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an unordered list is opened.

        Default implementation is:

         out.append("<ul>\n");
         
        Specified by:
        openUnorderedList in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • closeUnorderedList

        public void closeUnorderedList​(@Nonnull
                                       com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an unordered list is closed.

        Default implementation is:

         out.append("</ul>\n");
         
        Specified by:
        closeUnorderedList in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openListItem

        @Nonnull
        public HCLI openListItem​(@Nonnull
                                 com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a list item is opened.

        Note: Don't close the HTML tag!

        Default implementation is:

         out.append("<li");
         
        Specified by:
        openListItem in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
        Returns:
        List item element
      • closeListItem

        public void closeListItem​(@Nonnull
                                  com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a list item is closed.

        Default implementation is:

         out.append("</li>\n");
         
        Specified by:
        closeListItem in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • appendHorizontalRuler

        public void appendHorizontalRuler​(@Nonnull
                                          com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a horizontal ruler is encountered.

        Default implementation is:

         out.append("<hr />\n");
         
        Specified by:
        appendHorizontalRuler in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
      • openLink

        @Nonnull
        public HCA openLink​(@Nonnull
                            com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when a link is opened.

        Note: Don't close the HTML tag!

        Default implementation is:

         out.append("<a");
         
        Specified by:
        openLink in interface IMarkdownDecorator
        Parameters:
        out - The stack to write to.
        Returns:
        Link element
      • appendImage

        @Nonnull
        public HCImg appendImage​(@Nonnull
                                 com.helger.html.markdown.MarkdownHCStack out)
        Description copied from interface: IMarkdownDecorator
        Called when an image is opened.

        Note: Don't close the HTML tag!

        Default implementation is:

         out.append("<img");
         
        Specified by:
        appendImage in interface IMarkdownDecorator
        Parameters:
        out - The StringBuilder to write to.
        Returns:
        Image element