Support defining text nodes directly in the root document
What does this MR do and why?
-
NOTICE: This change is behind a the
preserve_unchanged_markdown
feature flag. - Context: This change is part of a larger effort to preserve unchanged Markdown in the Content Editor. For this effort, we need to support client-side parsing of Markdown content.
This MR fixes a bug in the Content Editor’s client-side Markdown parser where text nodes that are direct children of the root document make the AST to ProseMirror document fail. The bug is fixed by wrapping those text nodes in a paragraph. This is what a text node looks like when it is a direct child of the root node:
{
"type": "root",
"children": [
{
"type": "html",
"value": "<i class=\"foo\">\n *bar*\n</i>",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 3,
"column": 5,
"offset": 28
}
}
}
],
}
That AST represents the Markdown snippet in example 164 of the Commonmark spec: https://spec.commonmark.org/0.30/#example-164
Screenshots or screen recordings
Before | After |
---|---|
![]() |
![]() |
How to set up and validate locally
- Edit or create a Wiki page
- Enter the following Markdown snippet in the Classic Markdown Editor. The example comes from the Markdown spec: https://spec.commonmark.org/0.30/#example-164
<i class="foo"> *bar* </i>
- Switch to rich text mode. You should see the same result as the screenshots above.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Enrique Alcántara