Start with the builder method to configure the renderer. Example:
HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
renderer.render(node);
| Modifier and Type | Class and Description |
|---|---|
| public static class | HtmlRenderer.
Builder for configuring an |
| public static interface | HtmlRenderer.
Extension for |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final boolean | |
| private final List | |
| private final boolean | |
| private final boolean | |
| private final String | |
| private final UrlSanitizer |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static HtmlRenderer. | |
| public void | render(Node node, Appendable output)
Implements jdk. Render the tree of nodes to output. |
| public String | render(Node node)
Implements jdk. Render the tree of nodes to string. |
| attributeProviderFactories | back to summary |
|---|---|
| private final List<AttributeProviderFactory> attributeProviderFactories | |
| escapeHtml | back to summary |
|---|---|
| private final boolean escapeHtml | |
| nodeRendererFactories | back to summary |
|---|---|
| private final List<HtmlNodeRendererFactory> nodeRendererFactories | |
| percentEncodeUrls | back to summary |
|---|---|
| private final boolean percentEncodeUrls | |
| sanitizeUrls | back to summary |
|---|---|
| private final boolean sanitizeUrls | |
| softbreak | back to summary |
|---|---|
| private final String softbreak | |
| urlSanitizer | back to summary |
|---|---|
| private final UrlSanitizer urlSanitizer | |
| HtmlRenderer | back to summary |
|---|---|
| private HtmlRenderer(HtmlRenderer. | |
| builder | back to summary |
|---|---|
| public static HtmlRenderer. Create a new builder for configuring an
| |
| render | back to summary |
|---|---|
| public void render(Node node, Appendable output) Implements jdk. Doc from jdk. Render the tree of nodes to output.
| |
| render | back to summary |
|---|---|
| public String render(Node node) Implements jdk. Doc from jdk. Render the tree of nodes to string.
| |
HtmlRenderer. See methods for default configuration.
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private boolean | |
| private List | |
| private boolean | |
| private boolean | |
| private String | |
| private UrlSanitizer |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public HtmlRenderer. | Returns: thisthe attribute provider factory to add attributeProviderFactory)Add a factory for an attribute provider for adding/changing HTML attributes to the rendered tags. |
| public HtmlRenderer | |
| public HtmlRenderer. | Returns: thistrue for escaping, false for preserving raw HTML escapeHtml)Whether |
| public HtmlRenderer. | extensions(Iterable<? extends Extension>
extensions to use on this HTML renderer extensions)Returns: |
| public HtmlRenderer. | Returns: thisthe factory for creating a node renderer nodeRendererFactory)Add a factory for instantiating a node renderer (done when rendering). |
| public HtmlRenderer. | Returns: thistrue to percent-encode, false for leaving as-is percentEncodeUrls)Whether URLs of link or images should be percent-encoded, defaults to |
| public HtmlRenderer. | Returns: thistrue for sanitization, false for preserving raw attribute sanitizeUrls)Whether |
| public HtmlRenderer. | |
| public HtmlRenderer. | Returns: this
|
| attributeProviderFactories | back to summary |
|---|---|
| private List<AttributeProviderFactory> attributeProviderFactories | |
| escapeHtml | back to summary |
|---|---|
| private boolean escapeHtml | |
| nodeRendererFactories | back to summary |
|---|---|
| private List<HtmlNodeRendererFactory> nodeRendererFactories | |
| percentEncodeUrls | back to summary |
|---|---|
| private boolean percentEncodeUrls | |
| sanitizeUrls | back to summary |
|---|---|
| private boolean sanitizeUrls | |
| softbreak | back to summary |
|---|---|
| private String softbreak | |
| urlSanitizer | back to summary |
|---|---|
| private UrlSanitizer urlSanitizer | |
| Builder | back to summary |
|---|---|
| public Builder() | |
| attributeProviderFactory | back to summary |
|---|---|
| public HtmlRenderer. Add a factory for an attribute provider for adding/changing HTML attributes to the rendered tags.
| |
| build | back to summary |
|---|---|
public HtmlRenderer build()
| |
| escapeHtml | back to summary |
|---|---|
| public HtmlRenderer. Whether
Note that
| |
| extensions | back to summary |
|---|---|
public HtmlRenderer.
| |
| nodeRendererFactory | back to summary |
|---|---|
| public HtmlRenderer. 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.)
| |
| percentEncodeUrls | back to summary |
|---|---|
| public HtmlRenderer. Whether URLs of link or images should be percent-encoded, defaults to If enabled, the following is done:
| |
| sanitizeUrls | back to summary |
|---|---|
| public HtmlRenderer. Whether
| |
| softbreak | back to summary |
|---|---|
| public HtmlRenderer. The HTML to use for rendering a softbreak, defaults to
Set it to
Set it to
| |
| urlSanitizer | back to summary |
|---|---|
| public HtmlRenderer.
| |
HtmlRenderer.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| extend | back to summary |
|---|---|
| public void extend(HtmlRenderer. | |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final HtmlWriter | |
| private final NodeRendererMap |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public Map | extendAttributes(Node node, String tagName, Map<String, String> attributes)
Implements jdk. Let extensions modify the HTML tag attributes. |
| public String | |
| public HtmlWriter | |
| public void | render(Node node)
Implements jdk. Render the specified node and its children using the configured renderers. |
| private void | |
| public boolean | |
| public boolean | |
| public UrlSanitizer |
| attributeProviders | back to summary |
|---|---|
| private final List<AttributeProvider> attributeProviders | |
| htmlWriter | back to summary |
|---|---|
| private final HtmlWriter htmlWriter | |
| nodeRendererMap | back to summary |
|---|---|
| private final NodeRendererMap nodeRendererMap | |
| RendererContext | back to summary |
|---|---|
| private RendererContext(HtmlWriter htmlWriter) | |
| encodeUrl | back to summary |
|---|---|
| public String encodeUrl(String url) Implements jdk.
| |
| extendAttributes | back to summary |
|---|---|
| public Map Implements jdk. Doc from jdk. Let extensions modify the HTML tag attributes.
| |
| getSoftbreak | back to summary |
|---|---|
| public String getSoftbreak() Implements jdk.
| |
| getWriter | back to summary |
|---|---|
| public HtmlWriter getWriter() Implements jdk.
| |
| render | back to summary |
|---|---|
| public void render(Node node) Implements jdk. Doc from jdk. Render the specified node and its children using the configured renderers. This should be used to render child nodes; be careful not to pass the node that is being rendered, that would result in an endless loop.
| |
| setCustomAttributes | back to summary |
|---|---|
| private void setCustomAttributes(Node node, String tagName, Map<String, String> attrs) | |
| shouldEscapeHtml | back to summary |
|---|---|
| public boolean shouldEscapeHtml() Implements jdk.
| |
| shouldSanitizeUrls | back to summary |
|---|---|
| public boolean shouldSanitizeUrls() Implements jdk.
| |
| urlSanitizer | back to summary |
|---|---|
| public UrlSanitizer urlSanitizer() Implements jdk.
| |