Package org.commonmark.renderer.html
Class HtmlRenderer.RendererContext
java.lang.Object
org.commonmark.renderer.html.HtmlRenderer.RendererContext
- All Implemented Interfaces:
AttributeProviderContext
,HtmlNodeRendererContext
- Enclosing class:
HtmlRenderer
private class HtmlRenderer.RendererContext
extends Object
implements HtmlNodeRendererContext, AttributeProviderContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<AttributeProvider> private final HtmlWriter
private final NodeRendererMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLet extensions modify the HTML tag attributes.void
Render the specified node and its children using the configured renderers.private void
boolean
boolean
-
Field Details
-
htmlWriter
-
attributeProviders
-
nodeRendererMap
-
-
Constructor Details
-
RendererContext
-
-
Method Details
-
shouldEscapeHtml
public boolean shouldEscapeHtml()- Specified by:
shouldEscapeHtml
in interfaceHtmlNodeRendererContext
- Returns:
- whether HTML blocks and tags should be escaped or not
-
shouldSanitizeUrls
public boolean shouldSanitizeUrls()- Specified by:
shouldSanitizeUrls
in interfaceHtmlNodeRendererContext
- Returns:
- true if the
UrlSanitizer
should be used.
-
urlSanitizer
- Specified by:
urlSanitizer
in interfaceHtmlNodeRendererContext
- Returns:
- Sanitizer to use for securing
Link
href andImage
src ifHtmlNodeRendererContext.shouldSanitizeUrls()
is true.
-
encodeUrl
- Specified by:
encodeUrl
in interfaceHtmlNodeRendererContext
- Parameters:
url
- to be encoded- Returns:
- an encoded URL (depending on the configuration)
-
extendAttributes
public Map<String,String> extendAttributes(Node node, String tagName, Map<String, String> attributes) Description copied from interface:HtmlNodeRendererContext
Let extensions modify the HTML tag attributes.- Specified by:
extendAttributes
in interfaceHtmlNodeRendererContext
- Parameters:
node
- the node for which the attributes are appliedtagName
- the HTML tag name that these attributes are for (e.g.h1
,pre
,code
).attributes
- the attributes that were calculated by the renderer- Returns:
- the extended attributes with added/updated/removed entries
-
getWriter
- Specified by:
getWriter
in interfaceHtmlNodeRendererContext
- Returns:
- the HTML writer to use
-
getSoftbreak
- Specified by:
getSoftbreak
in interfaceHtmlNodeRendererContext
- Returns:
- HTML that should be rendered for a soft line break
-
render
Description copied from interface:HtmlNodeRendererContext
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.- Specified by:
render
in interfaceHtmlNodeRendererContext
- Parameters:
node
- the node to render
-
setCustomAttributes
-