Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-GFM-009

GitHub alerts render as admonitions

When a block quote starts with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION] in any case, the extension SHALL render it as an admonition of that type with the default title and the quoted lines as Markdown body, using the text after the marker as the title and ending the admonition where its block quote ends under CommonMark, lazy paragraph continuation lines included.

Step 1 of path 2 in StRS-MDOKFSTUDIO-GFM-002: from “A block quote starts with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION]” to “The alert is drawn as an admonition, and the document holds a raw HTML table”.

Scenarios 11

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

nominalEach alert type renders
Givena block quote starting with > [!warning] and a body line (and likewise [!NOTE], [!TIP], [!IMPORTANT] and [!CAUTION] in any case)
Whenthe preview is rendered
Thenan admonition titled Warning contains the body as Markdown
refusalUnknown alert type
Givena block quote starting with > [!FOO]
Whenthe preview is rendered
Thenit stays a plain block quote
nominalTitle from the marker line
InputOutcome
`> [!WARNING] Read this`the admonition title is Read this
`> [!WARNING]` alonethe title is the default Warning
nominalLegacy bold markers
Givena block quote whose first line is '> **Note**' (or **Important**, **Warning**, in any case) followed by text
Whenthe preview is rendered
Thena simple admonition of the marker's type (Note, Important or Warning) contains the text
refusalBold marker with extra text
Givena block quote line '> **Note** and more'
Whenthe preview is rendered
Thenit stays a plain block quote
boundaryThe first body line never becomes the title
InputOutcome
`> [!NOTE]`, `> # h`, `> b`the title is Note; `h` is a heading in the body, on line 2, before the paragraph `b`
`> [!NOTE]`, `> **Bold first**`, `>`, `> b`the title is Note; `Bold first` is a bold paragraph in the body
`> [!WARNING] Read this`, `> ## h`the title is Read this; `h` is a heading in the body
`> **Note**`, `> # h`the title is Note; `h` is a heading in the body
boundaryFences keep alert markers literal
InputOutcome
'> [!NOTE]' within a fenced code blockthe marker stays literal code and no admonition is produced
a fenced block followed by a real alertthe fence content is literal and the alert after it is an admonition
boundaryThe admonition ends where its block quote ends

An unquoted line continues the alert only as a lazy continuation line (CommonMark 0.31.2, section 5.1): the alert's last line leaves a paragraph open (the marker line counts) and the unquoted line is not blank and cannot start a block. On a lazy line the quote does not match, so any list marker starts a list there, while a quoted line keeps the paragraph rule (only `1.` or a bullet with text interrupts a paragraph). A lazy line stays paragraph text: it never underlines a setext heading, makes a table delimiter row or a MyST block break `+++`. This is how GitHub renders alerts. The same rule holds for an alert indented in a list item, read after the indentation. Lazy lines are read with the preview's MyST syntax, so other MyST-only block syntax on a lazy line (a comment `% c`, a target `(lbl)=`, a footnote definition `[^1]: n`, a math block `$$`) keeps its MyST meaning inside the admonition, where GitHub shows it as paragraph text.

InputOutcome
`> [!NOTE]`, `> a`, then the unquoted line `b` (or an indented ` b`)`b` is inside the admonition, in the same paragraph as `a`
`> [!NOTE]` directly followed by an unquoted linethe line is inside the admonition
`> [!NOTE]`, `> a`, `b`, `c`, `> d`one admonition; `a b c d` is one paragraph (quoted lines resume after lazy lines)
an alert followed by a blank line and a paragraphthe paragraph is outside the admonition and later source line numbers are unchanged
an alert whose paragraph is followed directly by a list item of any marker or number, an empty one included (`- item`, `1. item`, `2. x`, `-`, `1) b`), a heading, a code fence (backticks or tildes), a colon fence, a thematic break or an HTML block that can interrupt a paragraphthat block is outside the admonition
`> [!NOTE]`, `> a`, then the quoted line `> 2. x``2. x` stays text of the paragraph (a quoted `2.` item cannot interrupt it)
`> [!NOTE]`, `> a`, then an unquoted `===`, `--` or `=`the line is inside the admonition as paragraph text (`a ===`); the admonition keeps its default title and no heading is made
`> [!NOTE]`, `> a`, then an unquoted `+++` (or `+++ {"a": 1}`), then `b`the line is inside the admonition as paragraph text (`a +++ b`); no block break is made and the document renders
`> [!NOTE]`, `> | a | b |`, then an unquoted delimiter row `| - | - |` (or `a | b`, then `--|--`)the row is inside the admonition as paragraph text; no table is made
an unquoted line after a quoted heading, a quoted fenced or indented code block, a blank quoted line `>`, a quoted thematic break, a quoted table (a header row and a delimiter row with as many cells) or a quoted HTML block that is still openthe line is outside the admonition (no open paragraph to continue)
`> [!NOTE]`, `> <!-- c -->` (or any HTML block of CommonMark kinds 1 to 5 closed by its end marker), `> text`, then `lazy`the HTML block ends on its end marker, so `lazy` continues the paragraph `text` inside the admonition
`> [!NOTE]`, `> a`, `> <custom-x>` (a lone tag, which cannot interrupt a paragraph), then `lazy``lazy` is inside the admonition; after a blank quoted line the same tag starts an HTML block and `lazy` is outside
boundaryEvery block keeps the lines of the document

The alert is rewritten into an admonition of more lines before parsing; the source lines of the blocks (`data-line`, `data-end-line`, which the block editor opens, saves, cuts and moves) are still the lines of the file as written; the rule is that of SwRS-MDOKFSTUDIO-CORE-003, and the rows below are its alert cases.

InputOutcome
two consecutive alerts (lines 1-2 and 4-6), then a heading on line 8 and a paragraph on line 10the admonitions carry lines 1-2 and 4-6, their paragraphs 2 and 5-6, the heading 8 and the paragraph 10
any alert type, a bold marker or a titled alert, an alert ending the file without a final line break, a CRLF documentthe admonition starts on its marker line and ends on the alert's last line (quoted or lazy); every other block keeps its own lines
an alert followed directly by a lazy continuation line, then a blank line and a paragraphthe admonition and its paragraph end on the lazy line; the paragraph after keeps its own line
an alert followed directly by a list itemthe admonition ends on its last quoted line; the list keeps its own lines
an alert after a frontmatter block, inside a list item, a grid card, a tab item or between context tags (also kept as one raw HTML block)the same, counted in the whole file
an unclosed fence after an alertthe warning and the opening line shown as code carry the line of the fence
alert markers inside a fenced code blockthey stay literal and later lines are unchanged
boundaryAlerts inside a colon container

An admonition written with a colon fence closes at the first colon-only line at least as long as its own, and a container nested in another must use a shorter fence than the outer one; a `:::{note}` inside a `:::{card}` would therefore end the card early.

InputOutcome
an alert inside a `:::{card}`, a `:::{tab-item}` of a tab set or a three-colon card of a nested grid, followed by a paragraphthe admonition is a backtick directive; the paragraph stays inside the card or tab and the text after the container stays outside
the same documentsthe blocks carry the lines of the file as written (the tab panels carry the lines of their items)
an alert outside every colon containerit is a colon-fence admonition, as before
an alert whose body holds a colon container (a `::::{grid}` of `:::{card}`)the admonition's colon fence is longer than every colon fence of its body; the whole container stays inside the admonition and the text after the alert stays outside
boundaryCRLF documents
InputOutcome
an alert written with CRLF line endingsan admonition is produced
a CRLF document mixing a fence and an alertthe HTML equals the LF rendering

Implemented in 4

Tested by 9

Replaces

SwRS-MDOKFSTUDIO-GFM-010Alert marker text becomes the title superseded superseded by SwRS-MDOKFSTUDIO-GFM-009 Markdown file
SwRS-MDOKFSTUDIO-GFM-011Legacy bold markers render as admonitions superseded superseded by SwRS-MDOKFSTUDIO-GFM-009 Markdown file
SwRS-MDOKFSTUDIO-GFM-012Alert markers inside fences stay literal superseded superseded by SwRS-MDOKFSTUDIO-GFM-009 Markdown file
SwRS-MDOKFSTUDIO-GFM-013Alerts render the same in CRLF documents superseded superseded by SwRS-MDOKFSTUDIO-GFM-009 Markdown file
SwRS-MDOKFSTUDIO-GFM-037Alerts end at the first unquoted line superseded superseded by SwRS-MDOKFSTUDIO-GFM-009 Markdown file