-
-
Notifications
You must be signed in to change notification settings - Fork 421
postProcess
Marcos Caceres edited this page Mar 28, 2026
·
14 revisions
Type: Array<(config: Object, document: Document, utils: Object) => void | Promise<void>>
Default: []
An array of functions that run after ReSpec has finished all processing. Use this to add custom sections, validate the final output, or modify generated markup.
async function addImplStatus(config, document) {
const res = await fetch("https://api.example.org/impl-status.json");
const status = await res.json();
// Add a badge to each section that has implementation data
for (const [id, data] of Object.entries(status)) {
const section = document.getElementById(id);
if (!section) continue;
const badge = document.createElement("span");
badge.className = "impl-badge";
badge.textContent = `${data.implementations} implementations`;
section.querySelector("h2, h3")?.append(" ", badge);
}
}
var respecConfig = {
postProcess: [addImplStatus],
};function validateSpec(config, document) {
// Check that all normative sections have at least one dfn or algorithm
const normativeSections = document.querySelectorAll(
"section:not(.informative):not(.appendix)"
);
for (const section of normativeSections) {
if (!section.querySelector("dfn, ol.algorithm")) {
console.warn("Section with no dfn or algorithm:", section.id);
}
}
}
var respecConfig = {
postProcess: [validateSpec],
};Each function receives three arguments:
| Argument | Type | Description |
|---|---|---|
config |
Object |
The respecConfig object plus ReSpec internal state |
document |
Document |
The fully processed ReSpec document |
utils |
Object |
ReSpec utility functions |
- Functions run in order, awaiting async functions before proceeding
- At this point: headings are numbered, ToC is built, dfn panels are generated, xrefs are resolved, boilerplate is inserted. You are working with the final output.
- Changes appear in both the live preview and the saved HTML export
- To be notified when ALL processing is complete (including postProcess), use
document.respec.ready - For pre-processing before ReSpec starts, see
preProcess
💖 Support ReSpec by becoming a sponsor via Open Collective. 💖
✨ View rendered version of this documentation at https://respec.org/docs/ ✨
- Getting Started
- How Do I…
- Spec Editor's Guide
- Writing Algorithms
- WebIDL Guide
- Configuring ReSpec
- Developers Guide
- Shorthands
- addSectionLinks
- authors
- caniuse
- edDraftURI
- editors
- format (markdown)
- formerEditors
- github
- highlightVars
- isPreview
- license
- lint
- localBiblio
- logos
- maxTocLevel
- mdn
- modificationDate
- monetization
- noTOC
- otherLinks
- pluralize
- postProcess
- preProcess
- previousDiffURI
- previousMaturity
- previousPublishDate
- prevRecShortname
- prevRecURI
-
processVersion(Removed) - publishDate
- shortName
- specStatus
- subjectPrefix
- subtitle
- testSuiteURI
- xref
- additionalCopyrightHolders
-
addPatentNote(Removed) - alternateFormats
- canonicalURI
- charterDisclosureURI
- copyrightStart
- crEnd
- dark mode
- doJsonLd
- errata
- group
- implementationReportURI
- level
- noRecTrack
- prevED
- prEnd
- submissionCommentNumber
-
wg(Deprecated — usegroup) -
wgId(Deprecated — usegroup) -
wgPatentURI(Deprecated — usegroup) -
wgPublicList(Deprecated — usegroup) -
wgURI(Deprecated — usegroup)
a11ycheck-charsetcheck-internal-slotscheck-punctuationinformative-dfnlocal-refs-existno-captionless-tablesno-headingless-sectionsno-http-propsno-link-warningsno-unused-dfnsno-unused-varsprivsec-sectionwpt-tests-exist
Handled by ReSpec for you.
- conformance
- idl-index
- index
- issue-summary
- references
- tof (Table of Figures)
- data-abbr
- data-cite
- data-dfn-for
- data-dfn-type
- data-export
- data-format
- data-include
- data-include-format
- data-include-replace
- data-link-for
- data-link-type
- data-local-lt
- data-lt
- data-lt-no-plural
- data-lt-noDefault
- data-max-toc
- data-number
- data-oninclude
- data-sort
- data-tests
-
data-transform(Deprecated) - data-type
- dir
- lang