Behaviour SwRS-MDOKFSTUDIO-DIAG-023
PlantUML fences become centred inert pictures drawn by the built-in engine
When a document contains a plantuml fence, or a {plantuml} or {uml} directive with a body, the extension SHALL render a figure whose diagram element is labelled "PlantUML diagram" and holds the diagram text for the engine, with the same text in a collapsed "Diagram source" disclosure, which the built-in engine draws as one inert centred picture in the light or dark variant of the preview.
Step 1 of path 1 in StRS-MDOKFSTUDIO-DIAG-006: from “The document holds a PlantUML diagram” to “The diagram is drawn as a picture in the light or dark variant of the preview”.
Scenarios 7
The situations the tests check; open one to read it.
nominalThree forms
Givena plantuml fence, a {plantuml} directive and a {uml} directive, each with a body
Whenthe preview is rendered
Thenthree PlantUML figures appear, each with a diagram element labelled "PlantUML diagram" holding the text and a collapsed "Diagram source" disclosure with the same text
boundaryText kept as written
Givena body without an @startuml line
Whenthe preview is rendered
Thenthe diagram text is exactly the body; the extension adds no wrapper
boundaryThe JAR pipeline loads no built-in engine script
Giventhe JAR pipeline and content with a PlantUML figure
Whenthe page is built
Thenthe page holds no built-in engine script (the script of the built-in engine follows SwRS-MDOKFSTUDIO-DIAG-129)
nominalA valid diagram is drawn as a picture
Givena valid PlantUML sequence diagram
Whenthe page draws it with the built-in engine
Thenthe diagram element holds one image of class myst-plantuml-image with alt text "PlantUML diagram", a data:image/svg+xml source and data-render-state rendered; the source disclosure stays below
boundarySVG with a script
Givenengine output that contains a script element and a link
Whenthe page shows it
Thenthe output is an image, so the script does not run and the link cannot be followed
nominalLight or dark rendering follows the preview
| Preview background | Outcome |
|---|---|
| Computed background with a luminance below 0.18 | The page asks the built-in engine for the dark rendering |
| Computed background fully transparent | The light rendering is used |
| Any other background | The light rendering is used |
| Theme change from a dark to a light background | Every diagram is drawn again with the light rendering |
| Theme change that keeps the background dark | No diagram is drawn again |
boundaryPicture width, centring and source disclosure style
| Case | Outcome |
|---|---|
| PlantUML picture wider than the content column | Displayed at the column width with height auto, never set to a fixed width |
| PlantUML picture narrower than the column | Keeps its natural size and is centred (a block with margin-inline auto) |
| PlantUML picture as wide as the column | Fills the column |
| Source disclosure of a PlantUML figure | The summary uses the description colour, a pointer cursor and font size 0.9em, and the details has a top margin |
| Source disclosure of a Mermaid figure | Uses the same rules |
Implemented in 5
Tested by 5
Known limits (3)
- A PlantUML diagram with empty text is skipped by the engine and left blank, with no message (no test covers it).
- The engine runs under the unchanged Content Security Policy (no eval, no worker, no WebAssembly, no network); docs/preview-lifecycle.md notes harmless style-src-attr violations in the console.
- The theme observer in plantumlPreview.ts has no unit test.
Replaces
SwRS-MDOKFSTUDIO-DIAG-028The built-in PlantUML script loads only when needed superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-029Built-in PlantUML diagrams are drawn as inert pictures superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-030Built-in diagrams follow the light or dark preview superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-081PlantUML pictures are contained in the content width superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-083The PlantUML source disclosure is styled like Mermaid's superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-115A theme switch between light and dark redraws built-in diagrams superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file
SwRS-MDOKFSTUDIO-DIAG-119PlantUML pictures are centred superseded superseded by SwRS-MDOKFSTUDIO-DIAG-023 Markdown file