Repository navigation
mermaid
Marcos Caceres edited this page Dec 4, 2026
·
1 revision
ReSpec draws Mermaid diagrams from text. Wrap the diagram in a <figure> and ReSpec numbers it, captions it, and lists it in the Table of Figures like any other figure.
<figure id="release-flow">
<pre class="mermaid">
flowchart LR
A[Draft] --> B[Review] --> C[Publish]
</pre>
<figcaption>A change goes from draft to review before it is published</figcaption>
</figure>
<p>As shown in <a href="#release-flow"></a>, every change gets a review.</p>The empty <a href="#release-flow"> fills in "Figure N", the same as for any other figure.
In a Markdown document, a fenced block tagged mermaid becomes the same <figure>. A title after the tag becomes the <figcaption>:
```mermaid "title": "A change goes from draft to review before it is published"
flowchart LR
A[Draft] --> B[Review] --> C[Publish]
```- Write the diagram with Mermaid 12.1.0 syntax. ReSpec's tests cover flowcharts, sequence diagrams, class diagrams, state diagrams, and pie charts
- A
<figcaption>is required, as for any other figure. A fence without a"title"has no caption, so ReSpec warns about the missing caption - A Markdown fence has no
id. To link to the diagram, write the<figure>in HTML and give it anid - A
<pre class="mermaid">outside a<figure>still draws, but it gets no number and ReSpec warns: "Diagrams should be inside a<figure>." - A fence in a file pulled in with
data-includeworks too, when the include usesdata-include-format="markdown" - The
<figcaption>is the diagram's accessible name for screen readers - Readers get a button that flips the diagram to its text and a button that copies the text
- A wide diagram switches to a narrow layout on a phone
- In dark mode, the diagram follows the page colors
- Snapshots saved from the ReSpec menu keep the diagram and both buttons
- A mistake in the diagram text shows an error card in place of the drawing, with the failing line marked, and adds an error to the ReSpec pill
- "Could not load the diagram renderer." means the drawing code did not load. The diagrams stay as text. ReSpec runs that code as an inline script from a file named
respec-pele.jsnext to the ReSpec script, so it cannot load from afile://page, under a Content Security Policy that blocks inline scripts, or when that file is missing. Preview your spec overhttp://to see the diagrams - "Could not draw the diagrams: the fonts were still loading." means a web font took too long to load. Check the font links in your document and reload
- "Could not draw a diagram." is a bug in ReSpec, not in your diagram. Please file an issue with the diagram text
- Set
diagramstofalsein yourrespecConfigto leave every<pre class="mermaid">andmermaidfence alone - Other ReSpec profiles do not draw diagrams. In them, a
mermaidfence stays a normal code block - Also see Figures in the Editor's Guide
💖 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
- CDDL
- Configuring ReSpec
- Developers Guide
- Localizing ReSpec
- Shorthands
- addSectionLinks
- authors
- caniuse
- edDraftURI
- editors
- format (markdown)
- formerEditors
- github
- highlightVars
- implementationStatus
- 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