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
boundaryDuplicates in the language list
nominalA chosen language wraps the lines or inserts an empty fence
the caret in the paragraph para
json is chosen
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.
| Language | Input | Outcome |
|---|---|---|
| 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 |
| json | two 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
| Selection | Language | Outcome |
|---|---|---|
| `` echo ```x``` `` | bash | the outer fence has four backticks |
| x | text | the 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
a name with a space
the action runs with that name
the fence has no language either