Behaviour SwRS-MDOKFSTUDIO-LAYOUT-002
The text column width follows the maxContentWidth setting
When a preview page is built or the setting markdownOkfSchemaStudio.preview.maxContentWidth changes, the extension SHALL normalise the setting to a whole number of pixels from 0 to 2400 (960 when it is negative or not a finite number), write it into the page style as the width rule, and show a text column exactly that wide and centred in a wider pane, with no cap when the value is 0.
Step 1 of path 2 in StRS-MDOKFSTUDIO-LAYOUT-003: from “The setting maxContentWidth is changed” to “The text column is as wide as the setting says”.
Scenarios 8
The situations the tests check; open one to read it.
nominalDefault cap in a wide pane
Giventhe setting maxContentWidth at its default 960, Margin width mode, 100 percent zoom and a 1600 px pane
Whenthe preview is rendered
Thenthe content column is 960 px wide and the free space is split equally left and right
nominalConfigured cap above the default
GivenmaxContentWidth set to 1400 and a 2000 px pane (visual scenario v85)
Whenthe preview is rendered
Thenthe content column is exactly 1400 px wide and centred; in a pane narrower than the cap the column takes the pane width instead
boundaryNormalisation of the setting
| Input | Outcome |
|---|---|
| 2500 | 2400 |
| 1049.6 | 1050 |
| 2400 | stays 2400 |
| 0 | stays 0 (0 is not cut or replaced) |
| -1 | 960, the default |
| the text wide | 960, the default |
| NaN | 960, the default |
boundaryZero lifts the limit
GivenmaxContentWidth set to 0 and a 2000 px pane
Whenthe width rule is built and the preview is rendered
Thenthe rule reads :root { --sphinx-preview-content-max-width: none; } and the column is not limited to a pixel width
with maxContentWidth set to 1 the rule reads --sphinx-preview-content-max-width: 1px, because only 0 lifts the limit
with maxContentWidth set to 1 the rule reads --sphinx-preview-content-max-width: 1px, because only 0 lifts the limit
nominalConfigured width in the page style
GivenmaxContentWidth set to 1200
Whenthe page HTML is built
Thenthe page style ends with :root { --sphinx-preview-content-max-width: 1200px; }
refusalInvalid configured width in the page style
GivenmaxContentWidth set to a negative number
Whenthe page HTML is built
Thenthe page style carries 960px, the default
nominalOpen preview follows a change of the setting
Givenan open preview that has a last good render and maxContentWidth changed from 960 to 1200
Whenthe settings change event arrives
Thenthe session re-reads the preview configuration, schedules the incoming-changes refresh, and updates the preview from the last good render; the page shell now carries the new width rule, so the whole page is replaced (no in-place content patch)
refusalNo last good render or unrelated section
Givenan open preview that has no last good render yet, or a settings change outside the preview, PlantUML and frontmatter sections
Whenthe settings change event arrives
Thenthe preview is not updated (no change for an unrelated section; nothing to redraw without a last good render)
Implemented in 5
Tested by 7
- test/core/configuration/previewConfiguration.test.tsunit
- test/core/preview/layoutThemeStyles.test.tsunit
- test/core/preview/previewStyles.test.tsunit
- test/session/diagReq.settings.requirements.test.tsunit
- test/session/previewRuntimeFile.test.tsunit
- test/visual/scenarioDefinitions1.tsvisual
- test/visual/scenarioDefinitions2.tsvisual
Known limits (6)
- The titles of visual scenarios v05 and v06 say full width but they assert only the 960 px column.
- docs/user/settings.md says that with the setting at 0 the three width modes look the same, which is not exact: Full width keeps a 16 px side gutter where Margin and Auto keep a gutter of 16 to 78 px.
- The unit test asserts the rule text for 0 and 1200 only; the rendered column at 0 has no automated check.
- The full-page test PERF-11 matches only the number 720 in the inline style, not the whole text of the rule; the whole rule text is asserted on the builder alone.
- No automated test changes the setting on an open preview.
- The width rule is an inline style of the page shell and the shell key includes it, so a changed rule makes the content patch planner return nothing and the whole page is replaced; the scroll position is restored by the normal page reload path.
Replaces
SwRS-MDOKFSTUDIO-LAYOUT-003The maximum content width is rounded and capped at 2400 superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-002 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-004A width of zero lifts the column limit superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-002 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-005Each rendered page carries the width rule superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-002 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-006Open previews follow a change of the width setting superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-002 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-036A negative or non-numeric width falls back to 960 superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-002 Markdown file