Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-CORE-079

Inline code shows a front matter value of the document

When inline code in the body is exactly = this.field or =this.field and the front matter of the document holds a value for that field, the preview SHALL show that value as plain text in place of the inline code, and SHALL show the inline code as written with a warning style and report a warning when the field is missing.

Part of StRS-MDOKFSTUDIO-CORE-001, outside the paths drawn on its map.

Scenarios 5

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

nominalA field of the front matter in the text
Givena document whose front matter has `title: Hello` and a body line Title: followed by inline code that holds = this.title
Whenthe preview renders the document
Thenthe line reads "Title: Hello", the value is a span of plain text and no code element remains
nominalThe value follows the front matter
Giventhe same document shown in the preview
Whenthe front matter value changes, in the properties table or in the text editor
Thenthe next render shows the new value, and the source keeps the expression
boundaryTypes of value
Value of the fieldShown as
a string or a numberthe text
a booleantrue or false
a listits items joined with a comma and a space
an objectits YAML on one line, in flow style
a nested field, written this.a.bthe value at that path, through objects only

The form is inline code that holds exactly = this.field or =this.field, with at most one space after the equals sign. The number of backticks that delimit the inline code does not change its text: to show the form itself as code, keep a backtick inside the code (`` `= this.field` ``, shown with its backticks) or put it in a fenced block. The value is set as text: HTML and Markdown in it are never interpreted. A table of contents entry built from a heading that holds the form reads the value, and the heading anchor and the link of the entry are built from the value too (they agree, and they change when the value changes). An included file is part of the rendered document: its form reads the front matter of the including document. An empty object counts as without a value, like an empty list.

failureA field without a value
Givena field that is absent, empty or null, a path through a scalar, an inherited name such as toString, a document without front matter, or a front matter that is not valid YAML
Whenthe preview renders the inline code that names it
Thenthe inline code stays as written with a dashed warning underline and a title that says why, never an empty string, and the render reports one warning with the line (at most 20 per render)
boundaryCode that is not the form
Giveninline code such as `= this.title x`, `==this.title`, `= that.title`, `= this.` or `x = this.title`, inline code that keeps a backtick around the form such as `` `= this.title` ``, or a fenced block that holds the expression
Whenthe preview renders the document
Thenit is unchanged and no warning is reported

Implemented in 2

Tested by 3