Class HtmlRenderer.MainNodeRenderer.SubNodeRenderer
- java.lang.Object
-
- com.vladsch.flexmark.html.NodeRendererSubContext
-
- com.vladsch.flexmark.html.HtmlRenderer.MainNodeRenderer.SubNodeRenderer
-
- All Implemented Interfaces:
LinkResolverBasicContext,LinkResolverContext,NodeRendererContext
- Enclosing class:
- HtmlRenderer.MainNodeRenderer
private class HtmlRenderer.MainNodeRenderer.SubNodeRenderer extends NodeRendererSubContext implements NodeRendererContext
-
-
Field Summary
Fields Modifier and Type Field Description private HtmlRenderer.MainNodeRenderermyMainNodeRenderer-
Fields inherited from class com.vladsch.flexmark.html.NodeRendererSubContext
doNotRenderLinksNesting, htmlWriter, renderingHandlerWrapper, renderingNode
-
-
Constructor Summary
Constructors Constructor Description SubNodeRenderer(HtmlRenderer.MainNodeRenderer mainNodeRenderer, HtmlWriter htmlWriter, boolean inheritCurrentHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelegateRender()pass node rendering to previously registered handlervoiddoNotRenderLinks()Increment the do not render links in this context.voiddoNotRenderLinks(boolean doNotRenderLinks)Increment/Decrement the do not render links in this context.voiddoRenderLinks()Decrement the do not render links in this context.@NotNull java.lang.StringencodeUrl(@NotNull java.lang.CharSequence url)@NotNull MutableAttributesextendRenderingNodeAttributes(@NotNull AttributablePart part, Attributes attributes)Extend the attributes by extensions for the node being currently rendered.@NotNull MutableAttributesextendRenderingNodeAttributes(@NotNull Node node, @NotNull AttributablePart part, Attributes attributes)Extend the attributes by extensions for the node being currently rendered.@NotNull NodegetCurrentNode()@NotNull NodeRendererContextgetDelegatedSubContext(boolean inheritIndent)Creates a child rendering context that can be used to collect rendered html text of the previously registered node renderer.@NotNull DocumentgetDocument()protected intgetDoNotRenderLinksNesting()@NotNull HtmlRendererOptionsgetHtmlOptions()@NotNull HtmlWritergetHtmlWriter()java.lang.StringgetNodeId(@NotNull Node node)Get the id attribute for the given node.@NotNull DataHoldergetOptions()Get the current rendering contextDataHolder.@NotNull RenderingPhasegetRenderingPhase()@NotNull NodeRendererContextgetSubContext(boolean inheritIndent)Creates a child rendering context that can be used to collect rendered html text.booleanisDoNotRenderLinks()Whether the current rendering context has link rendering disabled.voidrender(@NotNull Node node)Render the specified node and its children using the configured renderers.voidrenderChildren(@NotNull Node parent)Render the children of the node, used by custom renderers@NotNull ResolvedLinkresolveLink(@NotNull LinkType linkType, @NotNull java.lang.CharSequence url, Attributes attributes, java.lang.Boolean urlEncode)Resolve link for rendering.@NotNull ResolvedLinkresolveLink(@NotNull LinkType linkType, @NotNull java.lang.CharSequence url, java.lang.Boolean urlEncode)Resolve link for rendering.-
Methods inherited from class com.vladsch.flexmark.html.NodeRendererSubContext
flushTo, flushTo
-
-
-
-
Field Detail
-
myMainNodeRenderer
private final HtmlRenderer.MainNodeRenderer myMainNodeRenderer
-
-
Constructor Detail
-
SubNodeRenderer
public SubNodeRenderer(HtmlRenderer.MainNodeRenderer mainNodeRenderer, HtmlWriter htmlWriter, boolean inheritCurrentHandler)
-
-
Method Detail
-
getNodeId
public java.lang.String getNodeId(@NotNull @NotNull Node node)Description copied from interface:NodeRendererContextGet the id attribute for the given node.- Specified by:
getNodeIdin interfaceNodeRendererContext- Parameters:
node- node for which to get an id, depends on theHtmlIdGeneratorassigned for the context. Default generator only creates ids forHeadingnodes or custom nodes that implementAnchorRefTargetinterface.- Returns:
- id string or null
-
getOptions
@NotNull public @NotNull DataHolder getOptions()
Description copied from interface:LinkResolverContextGet the current rendering contextDataHolder. These are the options passed or set on theHtmlRenderer.builder()or passed toHtmlRenderer.builder(DataHolder). To get the document options you should useLinkResolverContext.getDocument()as the data holder.- Specified by:
getOptionsin interfaceLinkResolverBasicContext- Specified by:
getOptionsin interfaceLinkResolverContext- Returns:
- the current renderer options
DataHolder
-
getHtmlOptions
@NotNull public @NotNull HtmlRendererOptions getHtmlOptions()
- Specified by:
getHtmlOptionsin interfaceNodeRendererContext- Returns:
- the
HtmlRendererOptionsfor the context.
-
getDocument
@NotNull public @NotNull Document getDocument()
- Specified by:
getDocumentin interfaceLinkResolverBasicContext- Specified by:
getDocumentin interfaceLinkResolverContext- Returns:
- the
Documentnode of the current context
-
getRenderingPhase
@NotNull public @NotNull RenderingPhase getRenderingPhase()
- Specified by:
getRenderingPhasein interfaceNodeRendererContext- Returns:
- current rendering phase
-
encodeUrl
@NotNull public @NotNull java.lang.String encodeUrl(@NotNull @NotNull java.lang.CharSequence url)- Specified by:
encodeUrlin interfaceLinkResolverContext- Parameters:
url- to be encoded- Returns:
- an encoded URL (depending on the configuration)
-
extendRenderingNodeAttributes
@NotNull public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull @NotNull AttributablePart part, Attributes attributes)
Description copied from interface:NodeRendererContextExtend the attributes by extensions for the node being currently rendered.- Specified by:
extendRenderingNodeAttributesin interfaceNodeRendererContext- Parameters:
part- the tag of the node being rendered, some nodes render multiple tags with attributesattributes- the attributes that were calculated by the renderer or null, these may be modified. To preserve originals pass a copy.- Returns:
- the extended attributes with added/updated/removed entries
-
extendRenderingNodeAttributes
@NotNull public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull @NotNull Node node, @NotNull @NotNull AttributablePart part, Attributes attributes)
Description copied from interface:NodeRendererContextExtend the attributes by extensions for the node being currently rendered.- Specified by:
extendRenderingNodeAttributesin interfaceNodeRendererContext- Parameters:
node- node for which to get attributespart- the tag of the node being rendered, some nodes render multiple tags with attributesattributes- the attributes that were calculated by the renderer or null, these may be modified. To preserve originals pass a copy.- Returns:
- the extended attributes with added/updated/removed entries
-
render
public void render(@NotNull @NotNull Node node)Description copied from interface:LinkResolverContextRender 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 interfaceLinkResolverContext- Parameters:
node- the node to render
-
delegateRender
public void delegateRender()
Description copied from interface:NodeRendererContextpass node rendering to previously registered handler- Specified by:
delegateRenderin interfaceNodeRendererContext
-
getCurrentNode
@NotNull public @NotNull Node getCurrentNode()
- Specified by:
getCurrentNodein interfaceLinkResolverContext- Returns:
- the current node being rendered
-
resolveLink
@NotNull public @NotNull ResolvedLink resolveLink(@NotNull @NotNull LinkType linkType, @NotNull @NotNull java.lang.CharSequence url, java.lang.Boolean urlEncode)
Description copied from interface:LinkResolverContextResolve link for rendering. Link Resolvers are going to be called until one returns ResolvedLink with getStatus() != LinkStatus.UnknownA resolver can replace the url but not change the status letting downstream resolvers handle the rest. This is useful when a resolver does partial processing like macro expansion but does not know how to handle the rest.
Core processing will simply pass the link as is. It is up to extension LinkResolvers and AttributeProviders to make sense of the link and applicable attributes based on status.
- Specified by:
resolveLinkin interfaceLinkResolverContext- Parameters:
linkType- type of link being rendered. Core defined links are Link, Image. Extensions can define their ownurl- link url texturlEncode- whether the link should be url encoded, if null then the value ofHtmlRenderer.PERCENT_ENCODE_URLSwill be used to determine whether the resolved URL is to be encoded.- Returns:
- resolved link url for this link and its resolved status
-
resolveLink
@NotNull public @NotNull ResolvedLink resolveLink(@NotNull @NotNull LinkType linkType, @NotNull @NotNull java.lang.CharSequence url, Attributes attributes, java.lang.Boolean urlEncode)
Description copied from interface:LinkResolverContextResolve link for rendering. Link Resolvers are going to be called until one returns ResolvedLink with getStatus() != LinkStatus.UnknownA resolver can replace the url but not change the status letting downstream resolvers handle the rest. This is useful when a resolver does partial processing like macro expansion but does not know how to handle the rest.
Core processing will simply pass the link as is. It is up to extension LinkResolvers and AttributeProviders to make sense of the link and applicable attributes based on status.
- Specified by:
resolveLinkin interfaceLinkResolverContext- Parameters:
linkType- type of link being rendered. Core defined links are Link, Image. Extensions can define their ownurl- link url textattributes- link attributesurlEncode- whether the link should be url encoded, if null then the value ofHtmlRenderer.PERCENT_ENCODE_URLSwill be used to determine whether the resolved URL is to be encoded.- Returns:
- resolved link url for this link and its resolved status
-
getSubContext
@NotNull public @NotNull NodeRendererContext getSubContext(boolean inheritIndent)
Description copied from interface:NodeRendererContextCreates a child rendering context that can be used to collect rendered html text. The child context inherits everything but the HtmlRenderer, renderedNode, renderingHandler and doNotRenderLinksNesting from the parent.- Specified by:
getSubContextin interfaceNodeRendererContext- Parameters:
inheritIndent- whether the html writer of the sub-context should inherit the current context's indentation level or start with 0 indentation- Returns:
- a new rendering context with a given appendable for its output
-
getDelegatedSubContext
@NotNull public @NotNull NodeRendererContext getDelegatedSubContext(boolean inheritIndent)
Description copied from interface:NodeRendererContextCreates a child rendering context that can be used to collect rendered html text of the previously registered node renderer. The child context inherits everything but the HtmlRenderer and doNotRenderLinksNesting from the parent.- Specified by:
getDelegatedSubContextin interfaceNodeRendererContext- Parameters:
inheritIndent- whether the html writer of the sub-context should inherit the current context's indentation level or start with 0 indentation- Returns:
- a new rendering context with a given appendable for its output
-
renderChildren
public void renderChildren(@NotNull @NotNull Node parent)Description copied from interface:LinkResolverContextRender the children of the node, used by custom renderers- Specified by:
renderChildrenin interfaceLinkResolverContext- Parameters:
parent- node the children of which are to be rendered
-
getHtmlWriter
@NotNull public @NotNull HtmlWriter getHtmlWriter()
- Specified by:
getHtmlWriterin interfaceNodeRendererContext- Overrides:
getHtmlWriterin classNodeRendererSubContext- Returns:
- the HTML writer to use
-
getDoNotRenderLinksNesting
protected int getDoNotRenderLinksNesting()
- Overrides:
getDoNotRenderLinksNestingin classNodeRendererSubContext
-
isDoNotRenderLinks
public boolean isDoNotRenderLinks()
Description copied from interface:NodeRendererContextWhether the current rendering context has link rendering disabled. When true any renderer that would render a link, should only output the text of that link and image links should not render anything.- Specified by:
isDoNotRenderLinksin interfaceNodeRendererContext- Overrides:
isDoNotRenderLinksin classNodeRendererSubContext- Returns:
- true if links should be output as only text.
- See Also:
NodeRendererContext.isDoNotRenderLinks(),NodeRendererContext.doNotRenderLinks(),NodeRendererContext.doRenderLinks(),NodeRendererContext.doNotRenderLinks(boolean)
-
doNotRenderLinks
public void doNotRenderLinks(boolean doNotRenderLinks)
Description copied from interface:NodeRendererContextIncrement/Decrement the do not render links in this context. This value will persist for the duration of the current node's render() method and will be restored upon return. Effectively it will persist for the rendering of the children of this node.- Specified by:
doNotRenderLinksin interfaceNodeRendererContext- Overrides:
doNotRenderLinksin classNodeRendererSubContext- Parameters:
doNotRenderLinks- if true then increment the doNotRenderLinks value, else decrement it- See Also:
NodeRendererContext.isDoNotRenderLinks(),NodeRendererContext.doNotRenderLinks(),NodeRendererContext.doRenderLinks(),NodeRendererContext.doNotRenderLinks(boolean)
-
doNotRenderLinks
public void doNotRenderLinks()
Description copied from interface:NodeRendererContextIncrement the do not render links in this context. This value will persist for the duration of the current node's render() method and will be restored upon return. Effectively it will persist for the rendering of the children of this node.- Specified by:
doNotRenderLinksin interfaceNodeRendererContext- Overrides:
doNotRenderLinksin classNodeRendererSubContext- See Also:
NodeRendererContext.isDoNotRenderLinks(),NodeRendererContext.doNotRenderLinks(),NodeRendererContext.doRenderLinks(),NodeRendererContext.doNotRenderLinks(boolean)
-
doRenderLinks
public void doRenderLinks()
Description copied from interface:NodeRendererContextDecrement the do not render links in this context. This value will persist for the duration of the current node's render() method and will be restored upon return. Effectively it will persist for the rendering of the children of this node.- Specified by:
doRenderLinksin interfaceNodeRendererContext- Overrides:
doRenderLinksin classNodeRendererSubContext- See Also:
NodeRendererContext.isDoNotRenderLinks(),NodeRendererContext.doNotRenderLinks(),NodeRendererContext.doRenderLinks(),NodeRendererContext.doNotRenderLinks(boolean)
-
-