Behaviour SwRS-MDOKFSTUDIO-REVIEW-133
HTML comments show as gray chips carried as data
When a document holds an HTML comment that is not a tool comment, the renderer SHALL write a gray chip labelled comment at the place of the comment, with the comment text kept as a text node in a hidden body and never written as HTML.
Step 1 of path 1 in StRS-MDOKFSTUDIO-REVIEW-012: from “A document holds an HTML comment” to “A chip stands in the text”.
Scenarios 9
The situations the tests check; open one to read it.
nominalOne-line block comment
Givena comment on line 3 between two paragraphs
Whenthe document is rendered
Thena block wrapper with data-line 3 and data-end-line 3 holds a chip reading comment, with role button, tabindex 0 and the comment text as title, and a hidden body with the same text
nominalMulti-line block comment
Givena comment from line 1 to line 4
Whenthe document is rendered
Thenthe wrapper spans lines 1 to 4 and the chip title keeps both text lines
nominalInline comment
| Input | Outcome |
|---|---|
| The text "a `<!-- inline note -->` b" | The paragraph holds a span wrapper with a chip titled inline note and a hidden span body with that text |
| A heading "## Plan `<!-- TODO fix later -->`" | The heading holds the chip and its attributes are those of the heading without the comment |
| A comment in a table cell | A gray chip is written inside the cell (untested) |
refusalComment text is never rendered as HTML
| Input | Outcome |
|---|---|
| A comment holding an img tag with an onerror attribute | The hidden body holds the tag as text and no element is created from it |
| A comment directly followed by a paragraph with markup | The markup is rendered as usual and not inside the comment |
nominalSeveral comments and comments next to lists
| Input | Outcome |
|---|---|
| The line "`<!-- a -->` `<!-- b -->`" | Two chips are written, one for each comment |
| Comments before a list, between two items and after the list | Each comment is a chip labelled comment, and the TODO comment is a green TODO chip, never a chip labelled with the comment opener |
| A raw HTML table next to comments | The table is unchanged |
refusalTool comments get no chip
| Input | Outcome |
|---|---|
| Comments markdownlint-disable MD013, prettier-ignore, toc, cspell:disable and vale off | No chip and no comment wrapper is written |
| A markdownlint comment and a note on one line | Only the note gets a chip (untested) |
| A comment starting with another word | A chip is written |
boundaryContext tags with a comment inside
| Input | Outcome |
|---|---|
| A context block holding inner TODO text | The admonition is produced and holds one chip |
| A context block holding a comment | The admonition holds the comment wrapper |
boundaryChips after the sanitizer
| Input | Outcome |
|---|---|
| A rendered comment chip is sanitized | The chip keeps role button, tabindex 0 and its title |
| A chip with an onclick attribute is sanitized | The attribute is removed (deduced from the test name, not asserted separately) |
boundaryAn HTML comment inside a tab item keeps its own source lines
Givena tab item that holds a paragraph and the comment `<!-- review: inner -->` on line 5
Whenthe document is rendered
Thenthe comment wrapper carries data-line 5 and data-end-line 5, the tab panel stays one block, and the paragraph beside the comment carries no source line