Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-FMSCHEMA-001

The frontmatter block is found by its fences and parsed as a YAML mapping

When a document starts with a `---` line, the extension SHALL take the lines up to the first later `---` or `...` line that stands alone on its line, with LF or CRLF endings, as the frontmatter block and show it as a properties table when it parses to a YAML mapping, or as one error row "Invalid frontmatter YAML: {parser message}" with an error badge of 1 when it does not, and render the Markdown body below the table or the error row in both cases.

Step 1 of path 1 in StRS-MDOKFSTUDIO-FMSCHEMA-001: from “A document starts with a `---` line and a YAML mapping” to “The properties table is shown”.

Scenarios 6

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

nominalClosing with three dashes or three dots
Givena document starting with `---`, a line `title: Hello` and a closing line `...` followed by a heading
Whenthe preview is rendered
Thena properties table at the top lists the field title with the value Hello and the heading follows it
boundaryWhere the closing fence is recognised
InputOutcome
A frontmatter line `note: wait...` followed by a closing `---` lineThe table lists the field note with the value `wait...`; the block closes at the `---` line, not at the dots inside the value
A closing `---` or `...` line followed by trailing spaces or tabsThe line still closes the block
A document whose opening fence, fields and closing fence all end with CRLFThe table lists the same fields and values as the LF form of the document
A CRLF document closed by a `...` lineThe block closes at the `...` line and the table lists the fields above it
A document with only the two fence linesThe block is valid and empty; it parses to null and gets the not-a-mapping error row (see the scenario on a block that is not a mapping)
refusalOpening fence without a closing fence
Givena document with `---`, the lines `title: Open` and `status: draft`, a heading and no closing fence line
Whenthe preview is rendered
a closing `---` line is inserted after the two fields and the preview refreshes
Thenthe document has no frontmatter and no properties table is shown
the table appears with the fields title and status
refusalInvalid YAML
InputOutcome
A document whose frontmatter is the single line `k: [a` followed by a headingThe table holds one alert row starting with "Invalid frontmatter YAML:" and the badge reads 1 error
A broken frontmatter that also names a type with a schemaNo schema is applied, no field row is listed and the single error row is shown
refusalA block that is not a mapping
InputOutcome
A frontmatter block holding the two list items `- a` and `- b`The table holds the error row "Invalid frontmatter YAML: Frontmatter is not a mapping." and the badge reads 1 error
A document whose frontmatter is only the two fence linesThe same error row is shown, because an empty block parses to null
A block that parses to a scalarThe same error row is shown
nominalThe body renders when the YAML is invalid
InputOutcome
A document whose frontmatter is the single line `k: [a` followed by a headingThe heading is rendered below the error row
The same document with `markdownOkfSchemaStudio.frontmatter.propertiesTable` falseNo error row appears and the heading is rendered

Implemented in 3

Tested by 6

Known limits (4)

Replaces

SwRS-MDOKFSTUDIO-FMSCHEMA-002A document without a closing fence has no frontmatter superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-001 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-003Frontmatter fences accept Windows line endings superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-001 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-017Invalid YAML gives one error row and an error badge superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-001 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-018Frontmatter that is not a mapping gives an error row superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-001 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-076Invalid YAML does not stop the body from rendering superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-001 Markdown file