Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-CODE-040

Code blocks sit on a dark Dark+ background in every preview theme by a setting

When a code block is shown and the setting preview.codeBlocks.darkBackground is on, the extension SHALL draw it on the Dark+ dark background with the Dark+ token colours in every preview theme, and when the setting is off, SHALL keep the preview theme background and draw the tokens in the Light+ colours.

Part of StRS-MDOKFSTUDIO-CODE-001, outside the paths drawn on its map.

Scenarios 6

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

nominalThe dark background is on by default
Givena document with Python, YAML and shell blocks and the preview in the cream, the white or the dark theme
Whenthe preview renders it with the setting on (the default)
Theneach block has the Dark+ editor background (`#1e1e1e`) and default text colour (`#d4d4d4`) and its tokens use the Dark+ colours
nominalTokens of a supported language are coloured
Givena document with a fenced `rust` block and a `python` block, in any VS Code theme
Whenthe preview renders the document
Thenkeywords, strings, numbers, additions, titles, attributes, deletions and comments of each block get the token colours of the VS Code editor (comments in green with Dark+), written as colour classes (`sd-` followed by the hex colour) that a stylesheet rule defines, never as an inline style
boundaryThe colours do not depend on the VS Code theme
Givena VS Code theme that defines no chart colours
Whenthe preview renders a highlighted block
Thenthe token colours are the same fixed colours, because the stylesheet carries them
boundaryThe setting off keeps the theme background
InputOutcome
setting off, cream or white themethe block keeps the code-block background of the theme; tokens use the Light+ colours
setting off, VS Code light theme in the current theme modetokens use the Light+ colours
setting off, dark themetokens use the Dark+ colours on the dark code-block background
inline code, any settingunchanged
nominalToken text stays readable
Givenevery token colour the highlighter can write
Whenit is drawn on its background (Dark+ on `#1e1e1e`, Light+ on the cream, grey and white code backgrounds)
Thenits contrast ratio is at least 4.5:1, a token colour of the Dark+ or Light+ theme below that is moved to the nearest tint that reaches it, and the line numbers on the dark background use `#9d9d9d`
refusalStrict policy of the page
Giventhe page content security policy, which allows no WebAssembly, no `eval` and no inline style
Whena block is highlighted
Thenthe highlighter runs on the JavaScript regular expression engine and writes colour classes, never a `style` attribute

Implemented in 3

Tested by 5