Class HtmlRenderer.Builder
- All Implemented Interfaces:
RendererBuilder, DataHolder, MutableDataHolder, MutableDataSetter
- Enclosing class:
HtmlRenderer
HtmlRenderer. See methods for default configuration.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Map<Class<?>, AttributeProviderFactory> (package private) HeaderIdGeneratorFactory(package private) List<LinkResolverFactory> (package private) List<NodeRendererFactory> Fields inherited from interface DataHolder
NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull HtmlRenderer.BuilderattributeProviderFactory(@NotNull AttributeProviderFactory attributeProviderFactory) Add an attribute provider for adding/changing HTML attributes to the rendered tags.@NotNull HtmlRendererbuild()@NotNull HtmlRenderer.BuildercontentResolverFactory(@NotNull UriContentResolverFactory contentResolverFactory) Add a factory for resolving URI to content@NotNull HtmlRenderer.BuilderescapeHtml(boolean escapeHtml) @NotNull HtmlRenderer.BuilderhtmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory) Add a factory for generating the header id attribute from the header's text@NotNull HtmlRenderer.BuilderindentSize(int indentSize) The size of the indent to use for hierarchical elements, default 0, means no indent, also fastest renderingbooleanisRendererType(@NotNull String supportedRendererType) @NotNull HtmlRenderer.BuilderlinkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory) Add a factory for instantiating a node renderer (done when rendering).protected booleanloadExtension(@NotNull Extension extension) Load extension if it is valid@NotNull HtmlRenderer.BuildernodeRendererFactory(@NotNull NodeRendererFactory nodeRendererFactory) Add a factory for instantiating a node renderer (done when rendering).@NotNull HtmlRenderer.BuilderpercentEncodeUrls(boolean percentEncodeUrls) Whether URLs of link or images should be percent-encoded, defaults tofalse.protected voidpreloadExtension(@NotNull Extension extension) Preload operation for extension, perform any data config and other operation needed for loading extensionprotected voidremoveApiPoint(@NotNull Object apiPoint) Remove apiPoint from state information@NotNull HtmlRenderer.BuilderThe HTML to use for rendering a softbreak, defaults to"\n"(meaning the rendered result doesn't have a line break).Methods inherited from class BuilderBase
addExtensionApiPoint, extensions, get, loadExtensions, removeExtensions, set, setMethods inherited from class MutableDataSet
clear, getOrCompute, merge, remove, setAll, setFrom, setIn, toDataSet, toImmutable, toMutableMethods inherited from class DataSet
aggregate, aggregate, aggregateActions, contains, equals, getAll, getKeys, hashCode, registerDataKeyAggregator, toStringMethods inherited from interface DataHolder
contains, getAll, getKeys, toDataSet, toImmutable, toMutable
-
Field Details
-
attributeProviderFactories
Map<Class<?>, AttributeProviderFactory> attributeProviderFactories -
nodeRendererFactories
List<NodeRendererFactory> nodeRendererFactories -
linkResolverFactories
List<LinkResolverFactory> linkResolverFactories -
htmlIdGeneratorFactory
HeaderIdGeneratorFactory htmlIdGeneratorFactory
-
-
Constructor Details
-
Builder
public Builder() -
Builder
-
-
Method Details
-
removeApiPoint
Description copied from class:BuilderBaseRemove apiPoint from state information- Specified by:
removeApiPointin classBuilderBase<HtmlRenderer.Builder>- Parameters:
apiPoint- api point object
-
preloadExtension
Description copied from class:BuilderBasePreload operation for extension, perform any data config and other operation needed for loading extension- Specified by:
preloadExtensionin classBuilderBase<HtmlRenderer.Builder>- Parameters:
extension- to preload
-
loadExtension
Description copied from class:BuilderBaseLoad extension if it is valid- Specified by:
loadExtensionin classBuilderBase<HtmlRenderer.Builder>- Parameters:
extension- to load- Returns:
- true if extension was loaded
-
build
- Specified by:
buildin classBuilderBase<HtmlRenderer.Builder>- Returns:
- the configured
HtmlRenderer
-
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
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
WhetherHtmlInlineandHtmlBlockshould be escaped, defaults tofalse.Note that
HtmlInlineis 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
-
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:
attributeProviderFactoryin 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:
linkResolverFactoryin 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:
contentResolverFactoryin 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:
htmlIdGeneratorFactoryin interfaceRendererBuilder- Parameters:
htmlIdGeneratorFactory- the factory for generating header tag id attributes- Returns:
this
-