Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-054

The Code block list wraps lines in a fence of a highlighted language

When the writer presses Code block, the extension SHALL open a menu that lists text first and then each language name and alias that the preview highlights, once and in sorted order, and wrap the touched lines, or an empty fence at the caret, in a fence that names the chosen language, is one backtick longer than the longest backtick run in the code and at least three long, and names no language when none or an invalid name is given.

Step 1 of path 2 in StRS-MDOKFSTUDIO-PALETTE-013: from “The palette is shown above the text box” to “The language menu is open”.

Scenarios 5

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

nominalReal list
Giventhe page built with the languages of the highlighter
Whenthe writer presses Code block
Thenthe entries are text followed by highlightLanguageNames in order, including python, py and yaml, and choosing python writes a python fence
boundaryDuplicates in the language list
Givena language list that contains text and a name twice
Whenthe registry is built
Thentext appears once at the start, each other name once, sorted
nominalA chosen language wraps the lines or inserts an empty fence
Giventhe selection x = 1
the caret in the paragraph para
Whenpython is chosen
json is chosen
Thenthe text is a python fence around x = 1 with x = 1 selected
a blank line and an empty json fence follow para and the caret is inside the fence

In this table `[ ]` marks the selection and `|` marks the caret.

LanguageInputOutcome
python`[x = 1]`a python fence around the selected `x = 1`
text`[a` newline `b]`a text fence around the two lines
python`ab[c` newline `d]ef` (selection starts and ends inside lines)the fence wraps the whole lines `abc` and `def`, selected
json`|` (blank line)the fence replaces the line, caret inside
json`para|``para`, blank line, an empty json fence, caret inside
jsontwo spaces then `|`the fence replaces the blank line, caret inside
text`x` newline `[a]` newline `y`the fence wraps the line a only
boundaryThe fence is longer than any backtick run
SelectionLanguageOutcome
`` echo ```x``` ``bashthe outer fence has four backticks
xtextthe fence has three backticks

The fence width equals the maximum of three and the longest run plus one.

refusalNo language or an invalid language name
Giventhe selection x
a name with a space
Whenthe action runs without an argument
the action runs with that name
Thenthe text is a fence without language around x
the fence has no language either

Implemented in 2

Tested by 2