type

HtmlRendererBuilder

src @Js
class HtmlRendererBuilder : Obj

Builder for configuring an HtmlRenderer.

methods

attrProviderFactory

Add a factory for an attribute provider for adding/changing HTML attributes to the rendered tags.

build

Get the configured HtmlRenderer

extensions

Configure the given extensions on this this renderer

nodeRendererFactory

Add a factory for instantiating a node renderer (done when rendering).

withEscapeHtml

Whether HtmlInline and HtmlBlock should be escaped, defaults to false.

withOmitSingleParagraphP

Whether documents that only contain a single paragraph shoudl be rendered without the <p> tag.

withPercentEncodeUrls

Whether URLs of link or images should be percent-encoded, defaults to false.

withSanitizeUrls

Whether Image src and Link href should be sanitized, defaults to false.

withSoftBreak

The HTML to use for rendering a softbreak, default to \n (meaning the rendered result doesn't have a line break).

Slot Details

attrProviderFactory

src This attrProviderFactory(|HtmlContext->AttrProvider| factory)

Add a factory for an attribute provider for adding/changing HTML attributes to the rendered tags.

build

src HtmlRenderer build()

Get the configured HtmlRenderer

extensions

src This extensions(MarkdownExt[] exts)

Configure the given extensions on this this renderer

nodeRendererFactory

src This nodeRendererFactory(|HtmlContext->NodeRenderer| factory)

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 rendering for core node types can be overriden; the default rendering comes last).

withEscapeHtml

src This withEscapeHtml(Bool val := true)

Whether HtmlInline and HtmlBlock should be escaped, defaults to false.

Note that HtmlInline is only a tag itself, not the text between an opening tag and closing tag. So markup in the text will be parsed as normal and is not affected by this option.

withOmitSingleParagraphP

src This withOmitSingleParagraphP(Bool val := true)

Whether documents that only contain a single paragraph shoudl be rendered without the <p> tag. Set to true to render without the tag; the default of false always renders the tag.

withPercentEncodeUrls

src This withPercentEncodeUrls(Bool val := true)

Whether URLs of link or images should be percent-encoded, defaults to false.

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 encodeURL in JS).
  • Other characters such as umlauts are percent-encoded

withSanitizeUrls

src This withSanitizeUrls(Bool val := true)

Whether Image src and Link href should be sanitized, defaults to false.

withSoftBreak

src This withSoftBreak(Str s)

The HTML to use for rendering a softbreak, default to \n (meaning the rendered result doesn't have a line break).

Set it to <br> or <br /> to make the hard breaks.

Set it to (space) to ingore line wrapping in the source.