Class HtmlRenderer.Builder
- java.lang.Object
-
- com.vladsch.flexmark.util.data.DataSet
-
- com.vladsch.flexmark.util.data.MutableDataSet
-
- com.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder>
-
- com.vladsch.flexmark.html.HtmlRenderer.Builder
-
- All Implemented Interfaces:
RendererBuilder
,com.vladsch.flexmark.util.data.DataHolder
,com.vladsch.flexmark.util.data.MutableDataHolder
,com.vladsch.flexmark.util.data.MutableDataSetter
- Enclosing class:
- HtmlRenderer
public static class HtmlRenderer.Builder extends com.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder> implements RendererBuilder
Builder for configuring anHtmlRenderer
. See methods for default configuration.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull HtmlRenderer.Builder
attributeProviderFactory(@NotNull AttributeProviderFactory attributeProviderFactory)
Add an attribute provider for adding/changing HTML attributes to the rendered tags.@NotNull HtmlRenderer
build()
@NotNull HtmlRenderer.Builder
contentResolverFactory(@NotNull UriContentResolverFactory contentResolverFactory)
Add a factory for resolving URI to content@NotNull HtmlRenderer.Builder
escapeHtml(boolean escapeHtml)
@NotNull HtmlRenderer.Builder
htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory)
Add a factory for generating the header id attribute from the header's text@NotNull HtmlRenderer.Builder
indentSize(int indentSize)
The size of the indent to use for hierarchical elements, default 0, means no indent, also fastest renderingboolean
isRendererType(@NotNull String supportedRendererType)
@NotNull HtmlRenderer.Builder
linkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory)
Add a factory for instantiating a node renderer (done when rendering).protected boolean
loadExtension(@NotNull com.vladsch.flexmark.util.misc.Extension extension)
@NotNull HtmlRenderer.Builder
nodeRendererFactory(@NotNull NodeRendererFactory nodeRendererFactory)
Add a factory for instantiating a node renderer (done when rendering).@NotNull HtmlRenderer.Builder
percentEncodeUrls(boolean percentEncodeUrls)
Whether URLs of link or images should be percent-encoded, defaults tofalse
.protected void
preloadExtension(@NotNull com.vladsch.flexmark.util.misc.Extension extension)
protected void
removeApiPoint(@NotNull Object apiPoint)
@NotNull HtmlRenderer.Builder
softBreak(@NotNull String softBreak)
The HTML to use for rendering a softbreak, defaults to"\n"
(meaning the rendered result doesn't have a line break).-
Methods inherited from class com.vladsch.flexmark.util.builder.BuilderBase
addExtensionApiPoint, extensions, get, loadExtensions, removeExtensions, set, set
-
Methods inherited from class com.vladsch.flexmark.util.data.MutableDataSet
clear, getOrCompute, merge, remove, setAll, setFrom, setIn, toDataSet, toImmutable, toMutable
-
Methods inherited from class com.vladsch.flexmark.util.data.DataSet
aggregate, aggregate, aggregateActions, contains, equals, getAll, getKeys, hashCode, registerDataKeyAggregator, toString
-
-
-
-
Method Detail
-
removeApiPoint
protected void removeApiPoint(@NotNull @NotNull Object apiPoint)
- Specified by:
removeApiPoint
in classcom.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder>
-
preloadExtension
protected void preloadExtension(@NotNull @NotNull com.vladsch.flexmark.util.misc.Extension extension)
- Specified by:
preloadExtension
in classcom.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder>
-
loadExtension
protected boolean loadExtension(@NotNull @NotNull com.vladsch.flexmark.util.misc.Extension extension)
- Specified by:
loadExtension
in classcom.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder>
-
build
@NotNull public @NotNull HtmlRenderer build()
- Specified by:
build
in classcom.vladsch.flexmark.util.builder.BuilderBase<HtmlRenderer.Builder>
- Returns:
- the configured
HtmlRenderer
-
softBreak
@NotNull public @NotNull HtmlRenderer.Builder softBreak(@NotNull @NotNull String softBreak)
The HTML to use for rendering a softbreak, defaults to"\n"
(meaning the rendered result doesn't have a line break).Set it to
"<br>"
(or"<br />"
to make them hard breaks.Set it to
" "
to ignore line wrapping in the source.- Parameters:
softBreak
- HTML for softbreak- Returns:
this
-
indentSize
@NotNull public @NotNull HtmlRenderer.Builder indentSize(int indentSize)
The size of the indent to use for hierarchical elements, default 0, means no indent, also fastest rendering- Parameters:
indentSize
- number of spaces per indent- Returns:
this
-
escapeHtml
@NotNull public @NotNull HtmlRenderer.Builder escapeHtml(boolean escapeHtml)
WhetherHtmlInline
andHtmlBlock
should be escaped, defaults tofalse
.Note that
HtmlInline
is only a tag itself, not the text between an opening tag and a closing tag. So markup in the text will be parsed as normal and is not affected by this option.- Parameters:
escapeHtml
- true for escaping, false for preserving raw HTML- Returns:
this
-
isRendererType
public boolean isRendererType(@NotNull @NotNull String supportedRendererType)
-
percentEncodeUrls
@NotNull public @NotNull HtmlRenderer.Builder percentEncodeUrls(boolean percentEncodeUrls)
Whether URLs of link or images should be percent-encoded, defaults tofalse
.If enabled, the following is done:
- Existing percent-encoded parts are preserved (e.g. "%20" is kept as "%20")
- Reserved characters such as "/" are preserved, except for "[" and "]" (see encodeURI in JS)
- Unreserved characters such as "a" are preserved
- Other characters such umlauts are percent-encoded
- Parameters:
percentEncodeUrls
- true to percent-encode, false for leaving as-is- Returns:
this
-
attributeProviderFactory
@NotNull public @NotNull HtmlRenderer.Builder attributeProviderFactory(@NotNull @NotNull AttributeProviderFactory attributeProviderFactory)
Add an attribute provider for adding/changing HTML attributes to the rendered tags.- Specified by:
attributeProviderFactory
in interfaceRendererBuilder
- Parameters:
attributeProviderFactory
- the attribute provider factory to add- Returns:
this
-
nodeRendererFactory
@NotNull public @NotNull HtmlRenderer.Builder nodeRendererFactory(@NotNull @NotNull NodeRendererFactory nodeRendererFactory)
Add a factory for instantiating a node renderer (done when rendering). This allows to override the rendering of node types or define rendering for custom node types.If multiple node renderers for the same node type are created, the one from the factory that was added first "wins". (This is how the rendering for core node types can be overridden; the default rendering comes last.)
- Parameters:
nodeRendererFactory
- the factory for creating a node renderer- Returns:
this
-
linkResolverFactory
@NotNull public @NotNull HtmlRenderer.Builder linkResolverFactory(@NotNull @NotNull LinkResolverFactory linkResolverFactory)
Add a factory for instantiating a node renderer (done when rendering). This allows to override the rendering of node types or define rendering for custom node types.If multiple node renderers for the same node type are created, the one from the factory that was added first "wins". (This is how the rendering for core node types can be overridden; the default rendering comes last.)
- Specified by:
linkResolverFactory
in interfaceRendererBuilder
- Parameters:
linkResolverFactory
- the factory for creating a node renderer- Returns:
this
-
contentResolverFactory
@NotNull public @NotNull HtmlRenderer.Builder contentResolverFactory(@NotNull @NotNull UriContentResolverFactory contentResolverFactory)
Add a factory for resolving URI to content- Specified by:
contentResolverFactory
in interfaceRendererBuilder
- Parameters:
contentResolverFactory
- the factory for creating a node renderer- Returns:
this
-
htmlIdGeneratorFactory
@NotNull public @NotNull HtmlRenderer.Builder htmlIdGeneratorFactory(@NotNull @NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory)
Add a factory for generating the header id attribute from the header's text- Specified by:
htmlIdGeneratorFactory
in interfaceRendererBuilder
- Parameters:
htmlIdGeneratorFactory
- the factory for generating header tag id attributes- Returns:
this
-
-