Class HtmlRenderer

  • All Implemented Interfaces:
    IRender

    public class HtmlRenderer
    extends java.lang.Object
    implements IRender
    Renders a tree of nodes to HTML.

    Start with the builder() method to configure the renderer. Example:

    
     HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
     renderer.render(node);
     
    • Field Detail

      • SOFT_BREAK

        public static final DataKey<java.lang.String> SOFT_BREAK
      • HARD_BREAK

        public static final DataKey<java.lang.String> HARD_BREAK
      • STRONG_EMPHASIS_STYLE_HTML_OPEN

        public static final NullableDataKey<java.lang.String> STRONG_EMPHASIS_STYLE_HTML_OPEN
      • STRONG_EMPHASIS_STYLE_HTML_CLOSE

        public static final NullableDataKey<java.lang.String> STRONG_EMPHASIS_STYLE_HTML_CLOSE
      • EMPHASIS_STYLE_HTML_OPEN

        public static final NullableDataKey<java.lang.String> EMPHASIS_STYLE_HTML_OPEN
      • EMPHASIS_STYLE_HTML_CLOSE

        public static final NullableDataKey<java.lang.String> EMPHASIS_STYLE_HTML_CLOSE
      • CODE_STYLE_HTML_OPEN

        public static final NullableDataKey<java.lang.String> CODE_STYLE_HTML_OPEN
      • CODE_STYLE_HTML_CLOSE

        public static final NullableDataKey<java.lang.String> CODE_STYLE_HTML_CLOSE
      • INLINE_CODE_SPLICE_CLASS

        public static final NullableDataKey<java.lang.String> INLINE_CODE_SPLICE_CLASS
      • PERCENT_ENCODE_URLS

        public static final DataKey<java.lang.Boolean> PERCENT_ENCODE_URLS
      • INDENT_SIZE

        public static final DataKey<java.lang.Integer> INDENT_SIZE
      • ESCAPE_HTML

        public static final DataKey<java.lang.Boolean> ESCAPE_HTML
      • ESCAPE_HTML_BLOCKS

        public static final DataKey<java.lang.Boolean> ESCAPE_HTML_BLOCKS
      • ESCAPE_HTML_COMMENT_BLOCKS

        public static final DataKey<java.lang.Boolean> ESCAPE_HTML_COMMENT_BLOCKS
      • ESCAPE_INLINE_HTML

        public static final DataKey<java.lang.Boolean> ESCAPE_INLINE_HTML
      • ESCAPE_INLINE_HTML_COMMENTS

        public static final DataKey<java.lang.Boolean> ESCAPE_INLINE_HTML_COMMENTS
      • SUPPRESS_HTML

        public static final DataKey<java.lang.Boolean> SUPPRESS_HTML
      • SUPPRESS_HTML_BLOCKS

        public static final DataKey<java.lang.Boolean> SUPPRESS_HTML_BLOCKS
      • SUPPRESS_HTML_COMMENT_BLOCKS

        public static final DataKey<java.lang.Boolean> SUPPRESS_HTML_COMMENT_BLOCKS
      • SUPPRESS_INLINE_HTML

        public static final DataKey<java.lang.Boolean> SUPPRESS_INLINE_HTML
      • SUPPRESS_INLINE_HTML_COMMENTS

        public static final DataKey<java.lang.Boolean> SUPPRESS_INLINE_HTML_COMMENTS
      • SOURCE_WRAP_HTML

        public static final DataKey<java.lang.Boolean> SOURCE_WRAP_HTML
      • SOURCE_WRAP_HTML_BLOCKS

        public static final DataKey<java.lang.Boolean> SOURCE_WRAP_HTML_BLOCKS
      • HEADER_ID_GENERATOR_RESOLVE_DUPES

        public static final DataKey<java.lang.Boolean> HEADER_ID_GENERATOR_RESOLVE_DUPES
      • HEADER_ID_GENERATOR_TO_DASH_CHARS

        public static final DataKey<java.lang.String> HEADER_ID_GENERATOR_TO_DASH_CHARS
      • HEADER_ID_GENERATOR_NON_DASH_CHARS

        public static final DataKey<java.lang.String> HEADER_ID_GENERATOR_NON_DASH_CHARS
      • HEADER_ID_GENERATOR_NO_DUPED_DASHES

        public static final DataKey<java.lang.Boolean> HEADER_ID_GENERATOR_NO_DUPED_DASHES
      • HEADER_ID_GENERATOR_NON_ASCII_TO_LOWERCASE

        public static final DataKey<java.lang.Boolean> HEADER_ID_GENERATOR_NON_ASCII_TO_LOWERCASE
      • HEADER_ID_REF_TEXT_TRIM_LEADING_SPACES

        public static final DataKey<java.lang.Boolean> HEADER_ID_REF_TEXT_TRIM_LEADING_SPACES
      • HEADER_ID_REF_TEXT_TRIM_TRAILING_SPACES

        public static final DataKey<java.lang.Boolean> HEADER_ID_REF_TEXT_TRIM_TRAILING_SPACES
      • HEADER_ID_ADD_EMOJI_SHORTCUT

        public static final DataKey<java.lang.Boolean> HEADER_ID_ADD_EMOJI_SHORTCUT
      • RENDER_HEADER_ID

        public static final DataKey<java.lang.Boolean> RENDER_HEADER_ID
      • GENERATE_HEADER_ID

        public static final DataKey<java.lang.Boolean> GENERATE_HEADER_ID
      • DO_NOT_RENDER_LINKS

        public static final DataKey<java.lang.Boolean> DO_NOT_RENDER_LINKS
      • FENCED_CODE_LANGUAGE_CLASS_PREFIX

        public static final DataKey<java.lang.String> FENCED_CODE_LANGUAGE_CLASS_PREFIX
      • FENCED_CODE_LANGUAGE_CLASS_MAP

        public static final DataKey<java.util.HashMap<java.lang.String,​java.lang.String>> FENCED_CODE_LANGUAGE_CLASS_MAP
      • FENCED_CODE_NO_LANGUAGE_CLASS

        public static final DataKey<java.lang.String> FENCED_CODE_NO_LANGUAGE_CLASS
      • FENCED_CODE_LANGUAGE_DELIMITERS

        public static final DataKey<java.lang.String> FENCED_CODE_LANGUAGE_DELIMITERS
      • SOURCE_POSITION_ATTRIBUTE

        public static final DataKey<java.lang.String> SOURCE_POSITION_ATTRIBUTE
      • SOURCE_POSITION_PARAGRAPH_LINES

        public static final DataKey<java.lang.Boolean> SOURCE_POSITION_PARAGRAPH_LINES
      • TYPE

        public static final DataKey<java.lang.String> TYPE
      • TAG_RANGES

        public static final DataKey<java.util.ArrayList<TagRange>> TAG_RANGES
      • RECHECK_UNDEFINED_REFERENCES

        public static final DataKey<java.lang.Boolean> RECHECK_UNDEFINED_REFERENCES
      • OBFUSCATE_EMAIL

        public static final DataKey<java.lang.Boolean> OBFUSCATE_EMAIL
      • OBFUSCATE_EMAIL_RANDOM

        public static final DataKey<java.lang.Boolean> OBFUSCATE_EMAIL_RANDOM
      • HTML_BLOCK_OPEN_TAG_EOL

        public static final DataKey<java.lang.Boolean> HTML_BLOCK_OPEN_TAG_EOL
      • HTML_BLOCK_CLOSE_TAG_EOL

        public static final DataKey<java.lang.Boolean> HTML_BLOCK_CLOSE_TAG_EOL
      • UNESCAPE_HTML_ENTITIES

        public static final DataKey<java.lang.Boolean> UNESCAPE_HTML_ENTITIES
      • AUTOLINK_WWW_PREFIX

        public static final DataKey<java.lang.String> AUTOLINK_WWW_PREFIX
      • SUPPRESSED_LINKS

        public static final DataKey<java.lang.String> SUPPRESSED_LINKS
      • NO_P_TAGS_USE_BR

        public static final DataKey<java.lang.Boolean> NO_P_TAGS_USE_BR
      • EMBEDDED_ATTRIBUTE_PROVIDER

        public static final DataKey<java.lang.Boolean> EMBEDDED_ATTRIBUTE_PROVIDER
      • MAX_TRAILING_BLANK_LINES

        public static final DataKey<java.lang.Integer> MAX_TRAILING_BLANK_LINES
      • MAX_BLANK_LINES

        public static final DataKey<java.lang.Integer> MAX_BLANK_LINES
      • CONVERT_TABS

        @Deprecated
        public static final int CONVERT_TABS
        Deprecated.
      • COLLAPSE_WHITESPACE

        @Deprecated
        public static final int COLLAPSE_WHITESPACE
        Deprecated.
      • SUPPRESS_TRAILING_WHITESPACE

        @Deprecated
        public static final int SUPPRESS_TRAILING_WHITESPACE
        Deprecated.
      • PASS_THROUGH

        @Deprecated
        public static final int PASS_THROUGH
        Deprecated.
      • FORMAT_ALL

        @Deprecated
        public static final int FORMAT_ALL
        Deprecated.
      • RENDERER_TYPE_EQUIVALENCE

        public static final DataKey<java.util.List<Pair<java.lang.String,​java.lang.String>>> RENDERER_TYPE_EQUIVALENCE
        Stores pairs of equivalent renderer types to allow extensions to resolve types not known to them

        Pair contains: rendererType, equivalentType

      • FORMAT_CONVERT_TABS

        @Deprecated
        public static final int FORMAT_CONVERT_TABS
        Deprecated.
      • FORMAT_COLLAPSE_WHITESPACE

        @Deprecated
        public static final int FORMAT_COLLAPSE_WHITESPACE
        Deprecated.
      • FORMAT_SUPPRESS_TRAILING_WHITESPACE

        @Deprecated
        public static final int FORMAT_SUPPRESS_TRAILING_WHITESPACE
        Deprecated.
      • FORMAT_ALL_OPTIONS

        @Deprecated
        public static final int FORMAT_ALL_OPTIONS
        Deprecated.
    • Method Detail

      • builder

        @NotNull
        public static HtmlRenderer.Builder builder​(@Nullable
                                                   DataHolder options)
        Create a new builder for configuring an HtmlRenderer.
        Parameters:
        options - initialization options
        Returns:
        a builder
      • getOptions

        @NotNull
        public DataHolder getOptions()
        Description copied from interface: IRender
        Get Options for parsing
        Specified by:
        getOptions in interface IRender
        Returns:
        DataHolder for options
      • render

        public void render​(@NotNull
                           Node node,
                           @NotNull
                           java.lang.Appendable output)
        Render a node to the appendable
        Specified by:
        render in interface IRender
        Parameters:
        node - node to render
        output - appendable to use for the output
      • render

        public void render​(@NotNull
                           Node node,
                           @NotNull
                           java.lang.Appendable output,
                           int maxTrailingBlankLines)
        Render a node to the appendable
        Parameters:
        node - node to render
        output - appendable to use for the output
      • render

        @NotNull
        public java.lang.String render​(@NotNull
                                       Node node)
        Render the tree of nodes to HTML.
        Specified by:
        render in interface IRender
        Parameters:
        node - the root node
        Returns:
        the rendered HTML.
      • isCompatibleRendererType

        public static boolean isCompatibleRendererType​(@NotNull
                                                       MutableDataHolder options,
                                                       @NotNull
                                                       java.lang.String supportedRendererType)
      • isCompatibleRendererType

        public static boolean isCompatibleRendererType​(@NotNull
                                                       MutableDataHolder options,
                                                       @NotNull
                                                       java.lang.String rendererType,
                                                       @NotNull
                                                       java.lang.String supportedRendererType)
      • addRenderTypeEquivalence

        @NotNull
        public static MutableDataHolder addRenderTypeEquivalence​(@NotNull
                                                                 MutableDataHolder options,
                                                                 @NotNull
                                                                 java.lang.String rendererType,
                                                                 @NotNull
                                                                 java.lang.String supportedRendererType)