Behaviour SwRS-MDOKFSTUDIO-DIAG-129
A diagram renderer script loads only when the page holds a figure of its engine
When the rendered content holds a diagram or chart figure, the extension SHALL add the script of that engine to the page once, with the page nonce, and SHALL add no script of an engine whose figure the page does not hold.
Part of StRS-MDOKFSTUDIO-DIAG-001, outside the paths drawn on its map.
Scenarios 3
The situations the tests check; open one to read it.
nominalThe script of an engine follows its figure
| Rendered content | Outcome |
|---|---|
| a Mermaid figure (class myst-mermaid-figure) | the page HTML holds one script tag with the page nonce, the bundle URL of mermaidPreview.js and the attribute data-sphinx-preview-mermaid |
| a PlantUML figure, with the built-in engine | one script tag with the page nonce, the bundle URL of plantumlPreview.js and the attribute data-sphinx-preview-plantuml |
| a chart figure (class myst-vega-figure) | one script tag with the page nonce, the source vegaPreview.js of the extension bundle and the attribute data-sphinx-preview-vega |
| several figures of one engine | the script of that engine appears once |
| figures of two engines | each of the two scripts appears once |
| a figure of one engine and none of another | the page holds no script tag of the other engine |
boundaryA figure appearing or leaving changes the page shell
Givena page with a Mermaid figure or a chart
Whena content update adds a figure of another engine, or removes the only figure of an engine
Thenthe shell key differs, so the page is loaded again with the scripts that its content needs instead of being patched in place
nominalThe Mermaid renderer loads the diagram types it needs
Givena document with a Mermaid figure
Whenthe page loads the renderer
Thenthe script tag is `type="module"` and its entry file is small
each diagram type and the layout engine are chunks fetched when a diagram needs them
each diagram type and the layout engine are chunks fetched when a diagram needs them