Output

output:before:html#

Hook emitted right before HTML output is returned. Return { html } for final transformation.

Type: hook (handler may return a value).

Payload:

  • html — HTML string about to be returned
  • root — optional root element when output is scoped (optional)
  • container — optional container element (optional)

Example:

app.on('output:before:html', ({ html }) => {
  return { html: stripInternalAttributes(html) };
});

output:before:json#

Hook emitted right before JSON output is returned. Return { json } for final transformation.

Type: hook (handler may return a value).

Payload:

  • json — parsed JSON document tree

Example:

app.on('output:before:json', ({ json }) => {
  return { json: pruneEmptyNodes(json) };
});

output:prepare:html#

Hook emitted while preparing HTML output. Return { html } to adjust serialized HTML before cleaning.

Type: hook (handler may return a value).

Payload:

  • html — raw HTML before the cleaning pass
  • root — optional root element when output is scoped (optional)
  • container — optional container element (optional)

Example:

app.on('output:prepare:html', ({ html, root }) => {
  if (root?.dataset?.draft) return { html: wrapDraft(html) };
  return { html };
});