Skip to main content

TRenderEngineOptions

reexport
interface TRenderEngineOptions<
  E extends string
> {
  cssProcessorConfig?: Partial<CSSProcessorConfig>;
  customizeHTMLModels?: (defaultHTMLElementModels: {
      a: HTMLElementModel<"a", mixed>;
      abbr: HTMLElementModel<"abbr", textual>;
      accesskey: HTMLElementModel<"accesskey", none>;
      acronym: HTMLElementModel<"acronym", textual>;
      address: HTMLElementModel<"address", block>;
      area: HTMLElementModel<"area", none>;
      article: HTMLElementModel<"article", block>;
      aside: HTMLElementModel<"aside", block>;
      audio: HTMLElementModel<"audio", none>;
      b: HTMLElementModel<"b", textual>;
      base: HTMLElementModel<"base", none>;
      bdi: HTMLElementModel<"bdi", textual>;
      bdo: HTMLElementModel<"bdo", textual>;
      big: HTMLElementModel<"big", textual>;
      blockquote: HTMLElementModel<"blockquote", block>;
      body: HTMLElementModel<"body", block>;
      br: HTMLElementModel<"br", textual>;
      button: HTMLElementModel<"button", none>;
      canvas: HTMLElementModel<"canvas", none>;
      caption: HTMLElementModel<"caption", none>;
      cite: HTMLElementModel<"cite", textual>;
      code: HTMLElementModel<"code", textual>;
      col: HTMLElementModel<"col", none>;
      colgroup: HTMLElementModel<"colgroup", none>;
      data: HTMLElementModel<"data", textual>;
      datalist: HTMLElementModel<"datalist", none>;
      dd: HTMLElementModel<"dd", block>;
      del: HTMLElementModel<"del", mixed>;
      details: HTMLElementModel<"details", none>;
      dfn: HTMLElementModel<"dfn", textual>;
      dialog: HTMLElementModel<"dialog", none>;
      dir: HTMLElementModel<"dir", block>;
      div: HTMLElementModel<"div", block>;
      dl: HTMLElementModel<"dl", block>;
      dt: HTMLElementModel<"dt", block>;
      em: HTMLElementModel<"em", textual>;
      embed: HTMLElementModel<"embed", none>;
      fieldset: HTMLElementModel<"fieldset", none>;
      figcaption: HTMLElementModel<"figcaption", block>;
      figure: HTMLElementModel<"figure", block>;
      footer: HTMLElementModel<"footer", block>;
      form: HTMLElementModel<"form", none>;
      h1: HTMLElementModel<"h1", block>;
      h2: HTMLElementModel<"h2", block>;
      h3: HTMLElementModel<"h3", block>;
      h4: HTMLElementModel<"h4", block>;
      h5: HTMLElementModel<"h5", block>;
      h6: HTMLElementModel<"h6", block>;
      head: HTMLElementModel<"head", none>;
      header: HTMLElementModel<"header", block>;
      hgroup: HTMLElementModel<"hgroup", block>;
      hr: HTMLElementModel<"hr", block>;
      i: HTMLElementModel<"i", textual>;
      iframe: HTMLElementModel<"iframe", none>;
      img: HTMLElementModel<"img", block>;
      input: HTMLElementModel<"input", none>;
      ins: HTMLElementModel<"ins", mixed>;
      kbd: HTMLElementModel<"kbd", textual>;
      label: HTMLElementModel<"label", none>;
      legend: HTMLElementModel<"legend", none>;
      li: HTMLElementModel<"li", block>;
      link: HTMLElementModel<"link", none>;
      listing: HTMLElementModel<"listing", block>;
      main: HTMLElementModel<"main", block>;
      map: HTMLElementModel<"map", none>;
      mark: HTMLElementModel<"mark", textual>;
      math: HTMLElementModel<"math", none>;
      menu: HTMLElementModel<"menu", block>;
      meta: HTMLElementModel<"meta", none>;
      meter: HTMLElementModel<"meter", none>;
      nav: HTMLElementModel<"nav", block>;
      object: HTMLElementModel<"object", none>;
      ol: HTMLElementModel<"ol", block>;
      optgroup: HTMLElementModel<"optgroup", none>;
      option: HTMLElementModel<"option", none>;
      output: HTMLElementModel<"output", none>;
      p: HTMLElementModel<"p", block>;
      param: HTMLElementModel<"param", none>;
      picture: HTMLElementModel<"picture", block>;
      plaintext: HTMLElementModel<"plaintext", block>;
      pre: HTMLElementModel<"pre", block>;
      progress: HTMLElementModel<"progress", none>;
      q: HTMLElementModel<"q", textual>;
      rp: HTMLElementModel<"rp", textual>;
      rt: HTMLElementModel<"rt", textual>;
      ruby: HTMLElementModel<"ruby", textual>;
      s: HTMLElementModel<"s", textual>;
      samp: HTMLElementModel<"samp", textual>;
      section: HTMLElementModel<"section", block>;
      select: HTMLElementModel<"select", none>;
      small: HTMLElementModel<"small", textual>;
      source: HTMLElementModel<"source", none>;
      span: HTMLElementModel<"span", textual>;
      strike: HTMLElementModel<"strike", textual>;
      strong: HTMLElementModel<"strong", textual>;
      sub: HTMLElementModel<"sub", textual>;
      summary: HTMLElementModel<"summary", none>;
      sup: HTMLElementModel<"sup", textual>;
      svg: HTMLElementModel<"svg", none>;
      table: HTMLElementModel<"table", block>;
      tbody: HTMLElementModel<"tbody", block>;
      td: HTMLElementModel<"td", block>;
      textarea: HTMLElementModel<"textarea", none>;
      tfoot: HTMLElementModel<"tfoot", block>;
      th: HTMLElementModel<"th", block>;
      thead: HTMLElementModel<"thead", block>;
      time: HTMLElementModel<"time", textual>;
      title: HTMLElementModel<"title", none>;
      tr: HTMLElementModel<"tr", block>;
      track: HTMLElementModel<"track", none>;
      tt: HTMLElementModel<"tt", textual>;
      u: HTMLElementModel<"u", textual>;
      ul: HTMLElementModel<"ul", block>;
      var: HTMLElementModel<"var", textual>;
      video: HTMLElementModel<"video", none>;
      wbr: HTMLElementModel<"wbr", textual>;
      xmp: HTMLElementModel<"xmp", block>;
    }) => HTMLModelRecord<TagName | E, HTMLContentModel>;
  dangerouslyDisableHoisting?: boolean;
  dangerouslyDisableWhitespaceCollapsing?: boolean;
  domVisitors?: DomVisitorCallbacks;
  htmlParserOptions?: Readonly<ParserOptions>;
  ignoreDomNode?: (node: Node, parent: NodeWithChildren) => unknown;
  ignoredDomTags?: Array<string>;
  removeLineBreaksAroundEastAsianDiscardSet?: boolean;
  selectDomRoot?: (node: NodeWithChildren) => any;
  setMarkersForTNode?: SetMarkersForTNode;
  stylesConfig?: StylesConfig;
}

Type Parameters#

E#

Fields#

cssProcessorConfig#

optional
cssProcessorConfig?: Partial<CSSProcessorConfig>;

Customization for CSS inline processing.

customizeHTMLModels#

optional
customizeHTMLModels?: (defaultHTMLElementModels: {
    a: HTMLElementModel<"a", mixed>;
    abbr: HTMLElementModel<"abbr", textual>;
    accesskey: HTMLElementModel<"accesskey", none>;
    acronym: HTMLElementModel<"acronym", textual>;
    address: HTMLElementModel<"address", block>;
    area: HTMLElementModel<"area", none>;
    article: HTMLElementModel<"article", block>;
    aside: HTMLElementModel<"aside", block>;
    audio: HTMLElementModel<"audio", none>;
    b: HTMLElementModel<"b", textual>;
    base: HTMLElementModel<"base", none>;
    bdi: HTMLElementModel<"bdi", textual>;
    bdo: HTMLElementModel<"bdo", textual>;
    big: HTMLElementModel<"big", textual>;
    blockquote: HTMLElementModel<"blockquote", block>;
    body: HTMLElementModel<"body", block>;
    br: HTMLElementModel<"br", textual>;
    button: HTMLElementModel<"button", none>;
    canvas: HTMLElementModel<"canvas", none>;
    caption: HTMLElementModel<"caption", none>;
    cite: HTMLElementModel<"cite", textual>;
    code: HTMLElementModel<"code", textual>;
    col: HTMLElementModel<"col", none>;
    colgroup: HTMLElementModel<"colgroup", none>;
    data: HTMLElementModel<"data", textual>;
    datalist: HTMLElementModel<"datalist", none>;
    dd: HTMLElementModel<"dd", block>;
    del: HTMLElementModel<"del", mixed>;
    details: HTMLElementModel<"details", none>;
    dfn: HTMLElementModel<"dfn", textual>;
    dialog: HTMLElementModel<"dialog", none>;
    dir: HTMLElementModel<"dir", block>;
    div: HTMLElementModel<"div", block>;
    dl: HTMLElementModel<"dl", block>;
    dt: HTMLElementModel<"dt", block>;
    em: HTMLElementModel<"em", textual>;
    embed: HTMLElementModel<"embed", none>;
    fieldset: HTMLElementModel<"fieldset", none>;
    figcaption: HTMLElementModel<"figcaption", block>;
    figure: HTMLElementModel<"figure", block>;
    footer: HTMLElementModel<"footer", block>;
    form: HTMLElementModel<"form", none>;
    h1: HTMLElementModel<"h1", block>;
    h2: HTMLElementModel<"h2", block>;
    h3: HTMLElementModel<"h3", block>;
    h4: HTMLElementModel<"h4", block>;
    h5: HTMLElementModel<"h5", block>;
    h6: HTMLElementModel<"h6", block>;
    head: HTMLElementModel<"head", none>;
    header: HTMLElementModel<"header", block>;
    hgroup: HTMLElementModel<"hgroup", block>;
    hr: HTMLElementModel<"hr", block>;
    i: HTMLElementModel<"i", textual>;
    iframe: HTMLElementModel<"iframe", none>;
    img: HTMLElementModel<"img", block>;
    input: HTMLElementModel<"input", none>;
    ins: HTMLElementModel<"ins", mixed>;
    kbd: HTMLElementModel<"kbd", textual>;
    label: HTMLElementModel<"label", none>;
    legend: HTMLElementModel<"legend", none>;
    li: HTMLElementModel<"li", block>;
    link: HTMLElementModel<"link", none>;
    listing: HTMLElementModel<"listing", block>;
    main: HTMLElementModel<"main", block>;
    map: HTMLElementModel<"map", none>;
    mark: HTMLElementModel<"mark", textual>;
    math: HTMLElementModel<"math", none>;
    menu: HTMLElementModel<"menu", block>;
    meta: HTMLElementModel<"meta", none>;
    meter: HTMLElementModel<"meter", none>;
    nav: HTMLElementModel<"nav", block>;
    object: HTMLElementModel<"object", none>;
    ol: HTMLElementModel<"ol", block>;
    optgroup: HTMLElementModel<"optgroup", none>;
    option: HTMLElementModel<"option", none>;
    output: HTMLElementModel<"output", none>;
    p: HTMLElementModel<"p", block>;
    param: HTMLElementModel<"param", none>;
    picture: HTMLElementModel<"picture", block>;
    plaintext: HTMLElementModel<"plaintext", block>;
    pre: HTMLElementModel<"pre", block>;
    progress: HTMLElementModel<"progress", none>;
    q: HTMLElementModel<"q", textual>;
    rp: HTMLElementModel<"rp", textual>;
    rt: HTMLElementModel<"rt", textual>;
    ruby: HTMLElementModel<"ruby", textual>;
    s: HTMLElementModel<"s", textual>;
    samp: HTMLElementModel<"samp", textual>;
    section: HTMLElementModel<"section", block>;
    select: HTMLElementModel<"select", none>;
    small: HTMLElementModel<"small", textual>;
    source: HTMLElementModel<"source", none>;
    span: HTMLElementModel<"span", textual>;
    strike: HTMLElementModel<"strike", textual>;
    strong: HTMLElementModel<"strong", textual>;
    sub: HTMLElementModel<"sub", textual>;
    summary: HTMLElementModel<"summary", none>;
    sup: HTMLElementModel<"sup", textual>;
    svg: HTMLElementModel<"svg", none>;
    table: HTMLElementModel<"table", block>;
    tbody: HTMLElementModel<"tbody", block>;
    td: HTMLElementModel<"td", block>;
    textarea: HTMLElementModel<"textarea", none>;
    tfoot: HTMLElementModel<"tfoot", block>;
    th: HTMLElementModel<"th", block>;
    thead: HTMLElementModel<"thead", block>;
    time: HTMLElementModel<"time", textual>;
    title: HTMLElementModel<"title", none>;
    tr: HTMLElementModel<"tr", block>;
    track: HTMLElementModel<"track", none>;
    tt: HTMLElementModel<"tt", textual>;
    u: HTMLElementModel<"u", textual>;
    ul: HTMLElementModel<"ul", block>;
    var: HTMLElementModel<"var", textual>;
    video: HTMLElementModel<"video", none>;
    wbr: HTMLElementModel<"wbr", textual>;
    xmp: HTMLElementModel<"xmp", block>;
  }) => HTMLModelRecord<TagName | E, HTMLContentModel>;

Customize supported tags in the engine.

Remarks

If you need to add new tags, always use lowercase names.

dangerouslyDisableHoisting#

optional
dangerouslyDisableHoisting?: boolean;

Disable hoisting. Note that your layout might break!

dangerouslyDisableWhitespaceCollapsing#

optional
dangerouslyDisableWhitespaceCollapsing?: boolean;

Disable whitespace collapsing. Especially useful if your html is being pre-processed server-side with a minifier.

domVisitors#

optional
domVisitors?: DomVisitorCallbacks;

An object which callbacks will be invoked when a DOM element or text node has been parsed and its children attached.

htmlParserOptions#

optional
htmlParserOptions?: Readonly<ParserOptions>;

Options for htmlparser2 library parser.

ignoreDomNode#

optional
ignoreDomNode?: (node: Node, parent: NodeWithChildren) => unknown;

Ignore specific DOM nodes.

Warning: when this function is invoked, the node has not yet been attached to its parent or siblings. Use the second argument (parent) if you need to perform logic based on parent.

Returns: true if this node should not be included in the DOM, anything else otherwise.

Remarks

The function is applied during parsing, thus with very little overhead. However, it means that one node next siblings won't be available.

ignoredDomTags#

optional
ignoredDomTags?: Array<string>;

A list of tags which should not be included in the DOM.

removeLineBreaksAroundEastAsianDiscardSet#

optional
removeLineBreaksAroundEastAsianDiscardSet?: boolean;

Remove line breaks around special east-asian characters such as defined here: https://www.w3.org/TR/2020/WD-css-text-3-20200429/#line-break-transform

Default: false

selectDomRoot#

optional
selectDomRoot?: (node: NodeWithChildren) => any;

Select the DOM root before TTree generation. For example, you could iterate over children until you reach an article element and return this element.

Remarks

Applied after DOM parsing, before normalization and TTree construction. Before normalization implies that a body will be added in the tree after selecting root.

setMarkersForTNode#

optional
setMarkersForTNode?: SetMarkersForTNode;

Customize markers logic by extracting markers from TNode properties such as classes, ids, attributes, tagName ...

Remarks

If you are using JavaScript, you can use module augmentation and declaration merging to add properties to the ​Markers shape.

stylesConfig#

optional
stylesConfig?: StylesConfig;

Various configuration for styling.