Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-MYST-031

Figures render with image, caption, label, width and alignment

When a document holds a `{figure}` directive with colon or backtick fences, the extension SHALL render a figure with its image, `:alt:`, caption, `:name:` as id, a validated width and a validated alignment, mapped as one block from opening line to closing fence.

Step 1 of path 1 in StRS-MDOKFSTUDIO-MYST-017: from “A document holds a figure directive” to “The figure is shown with its width and alignment”.

Scenarios 7

The situations the tests check; open one to read it.

nominalA figure renders with image, alt, caption and id
Givena `{figure}` with alt, name and a caption body
Whenthe preview renders
Thenthe figure shows image, alt, caption and id, the figure styles apply and the figure editor action is offered
boundaryFence form and caption source
InputOutcome
The same figure with backtick fencesit maps from opening to closing fence as one block, rendering like the colon form
A figure whose body supplies the textthe text appears as caption, equal to the body
A figure without bodyno caption is added
nominalA figure image outside the document folder loads
Giventhe long chapter with a figure whose image path is a sibling folder such as `../external-img/depot-graph.svg`
Whenthe preview renders
Thenthe image has a natural size above zero, and when the chapter is scrolled to the landmark it stays in the frame
nominalA valid width is kept

Applies to `{figure}` and `{image}`: a number, or a number with px, %, em or rem, is kept as data-okf-width; a plain number means pixels.

Given`:width: 60%` (or `50%` with align center)
Whenthe preview renders
Thendata-okf-width is 60% (both width and alignment kept) and the width attribute is removed
refusalAn invalid width is dropped
InputOutcome
`:width: calc(1px)`the width is dropped
`:width: 60%;position:fixed`the value is dropped and the sanitizer reports Removed an unsupported figure width
`:width: auto`the value is dropped and the sanitizer reports Removed an unsupported figure width
A hand-edited bad valuethe value is dropped and the sanitizer reports Removed an unsupported figure width

The figure still renders when its width is dropped.

nominalThe page applies the width, also after updates
Givenan image with `:width: 300`
Whenthe page runs
Thenthe image gets that width, applied from the page without inline styles, including after every in-place content update
InputOutcome
A left-floated figure with `:width: 50%` and a content updatethe figure takes the width, its image fills it and the percentage stays relative to the column
nominalAlignment sets an align class and float
InputOutcome
`:align: left`the figure and image get an align class and float left beside the text
`:align: right`the figure floats right, the next paragraph wraps beside it and top-level headings clear the float
`:align: center`the figure and image get an align class and are centred
An unknown alignmentit is ignored (dropped)

Implemented in 4

Tested by 5

Replaces

SwRS-MDOKFSTUDIO-CORE-059Use a figure body as its caption superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file
SwRS-MDOKFSTUDIO-CORE-063Keep figure width and alignment superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file
SwRS-MDOKFSTUDIO-MYST-032Figure images outside the document folder load superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file
SwRS-MDOKFSTUDIO-MYST-033Figure width values are validated superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file
SwRS-MDOKFSTUDIO-MYST-035Figure alignment sets align classes and float superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file
SwRS-MDOKFSTUDIO-MYST-091The figure directive renders with its own styles and actions superseded superseded by SwRS-MDOKFSTUDIO-MYST-031 Markdown file