Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-094

The host inserts a new block with clean blank lines

When the host writes a new block after a line, it SHALL put one blank line before it and one blank line after it (none after it at the end of the document), in the line endings of the document, and write nothing for an empty or whitespace-only text or for a line that is not in the document.

Step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-011: from “An empty insertion editor is open” to “The new block is in the document between its neighbours”.

Part of StRS-MDOKFSTUDIO-BLOCK-025, outside the paths drawn on its map.

Scenarios 8

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

nominalBetween blocks
Givena document with two blocks separated by a blank line and a new block inserted after the first
Whenthe host plans the insertion
Thenthe new text goes at the end of the first block's last line, preceded by a blank line and followed by the existing blank line
boundaryBlocks and the end of the document
InputOutcome
A block directly followed by a non-blank line, a block inserted after itA line break is added after the new block so that the next block is not glued to it
A document ending with a figure fence and a final line break, a block inserted after the closing fenceThe new block follows the closing fence after one blank line, with no separator after it
A document that ends with an image line and no final line break, a block inserted after that lineThe new block follows after one blank line, with no separator after it
boundaryThe first block (after line 0)
InputOutcome
A document that starts with frontmatterThe new text follows the closing fence and the frontmatter text is unchanged
A document that holds only frontmatterThe new block ends the document after one blank line
An empty documentThe document holds the new block followed by one line break
A document that starts with a heading and has no frontmatterThe new block comes first, followed by a blank line and then the heading
boundaryLine endings
InputOutcome
A document with CR LF line breaks, a block of two lines insertedEvery line break of the inserted text is CR LF
A document with LF line breaks only, a block insertedEvery line break of the inserted text is LF
A document whose lines end with a lone CR, a block of two lines inserted after line 1 or after a later lineThe block goes at the end of that line and every line break of the inserted text is CR; a line after the last CR is refused as missing
refusalA whitespace-only new block
InputOutcome
An insertion editor whose text is ` \n`, the final save arrivesThe document is unchanged and the edit ends
An insertion editor whose text is `Hello`, the final save arrivesThe block is inserted
boundaryTrailing line breaks are dropped
InputOutcome
A new block typed as `Hello\n\n`The document holds `Hello` followed by the planned separator only
A block typed as `a\n\nb`The inner blank line is kept
A new block typed as `\n\nHello` (leading blank lines), in LF, CR LF or lone CRThe leading blank lines are dropped and the block starts right after the separator
A new block typed as ` Hello`The indentation of the first non-blank line is kept
boundaryAn anchor line that is blank
InputOutcome
`- a`, a blank line and `Para`, a block inserted after line 2 (the blank line)The document is `- a`, a blank line, `New`, a blank line, `Para`: one separator before the block, not two
A block inserted after a non-blank lineThe prefix stays two line endings
refusalA line that does not exist
InputOutcome
A previewEditOpen with insertAfterLine beyond the last lineThe host registers no editor and the editor shows "The preview is stale. Refresh it before editing this block."
A previewEditOpen with insertAfterLine on the last lineThe empty source of the new block is sent

Implemented in 1

Tested by 2

Known limits (1)