Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-FMEDIT-043

A frontmatter edit changes only the lines of its field

When a writer saves a value, the extension SHALL change only the lines of that field and keep comments, quoting style, spacing, fences, body and line endings byte-identical, and refuse an edit that would leave a block that does not parse or whose keys are not exactly the expected ones.

Part of StRS-MDOKFSTUDIO-FMEDIT-005, outside the paths drawn on its map.

Step 1 of path 1 in StRS-MDOKFSTUDIO-FMEDIT-008: from “A field editor is open” to “The value is saved on the lines of its field and the diff holds only the edited field”.

Scenarios 6

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

nominalA value edit changes only its field
Givena document with a trailing comment on the title line and other fields
Whentitle is changed from Alpha to Beta
Thenonly the title line changes and its comment is kept
boundaryLine endings, fences and values that look like a fence
DocumentEditOutcome
CRLF endingsa value is changedonly the named field's lines change; the fences, body and line endings stay identical
closing fence of three dotsa value is changedthe closing fence is kept and only the edited line changes
title: To be continued... and status: draftstatus is changedexactly the status line changes and the block keeps its three keys (a value ending in ... or --- stays inside the block)
nominalAn added field is one inserted line in the file's line endings
Givena CRLF document with the fields title and status
Whenowner is added after title
Thenthe edit inserts exactly one line ended by CRLF
boundaryAn added list uses the compact sequence style
Givenan added list value
Whenthe field is written
Thenthe list uses the compact sequence style
boundaryAnchored or aliased values rewrite the whole block with the right data
BlockEditOutcome
a: &x 1 and b: 3a is set to 2the block parses to a: 2 and b: 3
a value that is edited as an objectsavedthe written block parses to the same data
refusalAn edit that loses or corrupts a key is refused
Patch checked by the patch guardOutcome
deletes the author keyrefused, no edit is applied; the host answers "The frontmatter YAML could not be updated."
duplicates the status keyrefused, no edit is applied; the same answer
leaves invalid YAMLrefused
a faithful patch of the status linepasses unchanged

Implemented in 2

Tested by 7

Replaces

SwRS-MDOKFSTUDIO-FMEDIT-039An added field is a single inserted line in the file's line endings superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-044Anchored or aliased values fall back to a whole-block rewrite superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-045A frontmatter edit that loses or corrupts a key is refused superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-046Values ending in three dots or dashes stay inside the block superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file