Behaviour SwRS-MDOKFSTUDIO-DIAG-125
SVG blocks are drawn inline after the sanitizer rebuilt them
When a document holds an svg fence or a raw svg element that fills a whole block, the preview SHALL draw it inline as a picture rebuilt from an allow-list of drawing elements and presentation attributes, with every id and reference renamed per picture, and SHALL draw an svg element inside a sentence, a comment, a math block, a code block or a raw HTML table as nothing.
Step 1 of path 2 in StRS-MDOKFSTUDIO-DIAG-015: from “A document holds an svg fence or a raw svg block” to “The drawing is in the page”.
Scenarios 3
The situations the tests check; open one to read it.
nominalA fence and a raw block are pictures
Givena document with an svg fence and, after a blank line, a raw svg element that holds its whole block (one line or several)
Whenthe preview renders it
Theneach is one figure of the class myst-svg-figure that holds one svg element with its viewBox and declared width, carries the data-line of its first line and the data-end-line of its last line, and no code block is left
refusalActive content and shared ids
Givenan svg with a script element, an on-handler, a foreignObject, a link to an https page, a style element, a use that points at another file, a javascript: or data: URL and a gradient whose id another picture also uses, an image-set() or src() value, and a use or url() that points at an id of another picture or of the page
Whenthe preview renders it
Thennone of these reaches the page, the render carries one warning that names what was removed, and each picture keeps its own ids with every url(#id) and href="#id" reference renamed with them
boundaryInline svg and unreadable source
Givenan svg element inside a sentence, and an svg fence that holds no svg element
Whenthe preview renders them
Thenthe first draws nothing and the second stays a code block with one warning
| Input | Outcome |
|---|---|
| svg fence | one picture |
| raw svg that starts a block after a blank line and ends its last line | one picture |
| svg inside a sentence | nothing |
| svg inside a code block or a fence | the code, unchanged |
| svg inside an html comment, a $$ math block or a raw html table | left as it is (the comment stays one comment); a table cell drops it |
| a `<!--` or `$$` inside a sentence or a code span, before a raw svg block or a code block | opens nothing: the later picture is drawn, the code block keeps its text |
| an author's aria-label (any text, parentheses included) | kept as written |
| a document comment that looks like a picture placeholder | stays a comment; the placeholder holds a per-render random token |
| svg left unclosed | not a picture; the scan stops at the next fence or after 2000 lines |