Skip to content
Marcos Caceres edited this page Mar 28, 2026 · 8 revisions

document.respec

ReSpec adds a respec object to document when it loads. Use it to wait for processing to complete, inspect errors and warnings, or export the processed HTML.

document.respec.ready

A Promise that resolves when ReSpec finishes all processing (including postProcess functions).

<script>
  document.addEventListener("DOMContentLoaded", async () => {
    await document.respec.ready;
    console.log("Errors:", document.respec.errors);
    console.log("Warnings:", document.respec.warnings);
  });
</script>

document.respec.errors

An array of errors found during processing.

document.respec.warnings

An array of warnings found during processing.

Each item in errors and warnings has:

Property Type Description
message string The error/warning message text
plugin string Name of the ReSpec plugin that generated it (e.g. "core/xref")
hint string Optional suggestion for how to fix it
title string Short form of the message (used as element tooltip)
elements HTMLElement[] The offending elements in the document, if applicable
details string Additional context or explanation
cause object The underlying error that caused this one, if any

document.respec.version

The current ReSpec version string (semver, e.g. "35.8.0").

document.respec.toHTML()

Returns a Promise that resolves with the fully-processed document markup as a string — the same output as "Save as HTML".

<script>
  document.addEventListener("DOMContentLoaded", async () => {
    await document.respec.ready;
    const html = await document.respec.toHTML();
    // Send to a server, save to disk, etc.
    await fetch("/save", { method: "POST", body: html });
  });
</script>

Notes

  • Always await document.respec.ready before reading errors/warnings — the arrays are populated incrementally during processing
  • The deprecated document.respecIsReady was a bare Promise on document; the modern form is document.respec.ready

Guides

Configuration options

W3C Configuration options

Linting rules

Internal properties

Handled by ReSpec for you.

Special <section> IDs

HTML elements

Custom Elements

HTML attributes

CSS Classes

Special properties

Clone this wiki locally