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 java.lang.Object implements HtmlNodeRendererContext, AttributeProviderContext
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<AttributeProvider>attributeProvidersprivate HtmlWriterhtmlWriterprivate NodeRendererMapnodeRendererMap
-
Constructor Summary
Constructors Modifier Constructor Description privateRendererContext(HtmlWriter htmlWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterRoot(Node node)voidbeforeRoot(Node node)java.lang.StringencodeUrl(java.lang.String url)java.util.Map<java.lang.String,java.lang.String>extendAttributes(Node node, java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> attributes)Let extensions modify the HTML tag attributes.java.lang.StringgetSoftbreak()HtmlWritergetWriter()voidrender(Node node)Render the specified node and its children using the configured renderers.private voidsetCustomAttributes(Node node, java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> attrs)booleanshouldEscapeHtml()booleanshouldOmitSingleParagraphP()booleanshouldSanitizeUrls()UrlSanitizerurlSanitizer()
-
-
-
Field Detail
-
htmlWriter
private final HtmlWriter htmlWriter
-
attributeProviders
private final java.util.List<AttributeProvider> attributeProviders
-
nodeRendererMap
private final NodeRendererMap nodeRendererMap
-
-
Constructor Detail
-
RendererContext
private RendererContext(HtmlWriter htmlWriter)
-
-
Method Detail
-
shouldEscapeHtml
public boolean shouldEscapeHtml()
- Specified by:
shouldEscapeHtmlin interfaceHtmlNodeRendererContext- Returns:
- whether HTML blocks and tags should be escaped or not
-
shouldOmitSingleParagraphP
public boolean shouldOmitSingleParagraphP()
- Specified by:
shouldOmitSingleParagraphPin interfaceHtmlNodeRendererContext- Returns:
- whether documents that only contain a single paragraph should be rendered without the
<p>tag
-
shouldSanitizeUrls
public boolean shouldSanitizeUrls()
- Specified by:
shouldSanitizeUrlsin interfaceHtmlNodeRendererContext- Returns:
- true if the
UrlSanitizershould be used.
-
urlSanitizer
public UrlSanitizer urlSanitizer()
- Specified by:
urlSanitizerin interfaceHtmlNodeRendererContext- Returns:
- Sanitizer to use for securing
Linkhref andImagesrc ifHtmlNodeRendererContext.shouldSanitizeUrls()is true.
-
encodeUrl
public java.lang.String encodeUrl(java.lang.String url)
- Specified by:
encodeUrlin interfaceHtmlNodeRendererContext- Parameters:
url- to be encoded- Returns:
- an encoded URL (depending on the configuration)
-
extendAttributes
public java.util.Map<java.lang.String,java.lang.String> extendAttributes(Node node, java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> attributes)
Description copied from interface:HtmlNodeRendererContextLet extensions modify the HTML tag attributes.- Specified by:
extendAttributesin 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
public HtmlWriter getWriter()
- Specified by:
getWriterin interfaceHtmlNodeRendererContext- Returns:
- the HTML writer to use
-
getSoftbreak
public java.lang.String getSoftbreak()
- Specified by:
getSoftbreakin interfaceHtmlNodeRendererContext- Returns:
- HTML that should be rendered for a soft line break
-
render
public void render(Node node)
Description copied from interface:HtmlNodeRendererContextRender 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:
renderin interfaceHtmlNodeRendererContext- Parameters:
node- the node to render
-
beforeRoot
public void beforeRoot(Node node)
-
afterRoot
public void afterRoot(Node node)
-
setCustomAttributes
private void setCustomAttributes(Node node, java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> attrs)
-
-