As described in the docs:
While the most common flavours of markdown let you use HTML in markdown paragraphs, due to how Svelte handles plain HTML it is currently not possible to do this with this package. A paragraph must be either all HTML or all markdown.
A way to solve this is to do a single-pass walk along tokens and then join tokens between the outmost html tokens.
For example:
Input Markdown
Ideal Result
a1
Tokens
[
{
"type": "text",
"raw": "a",
"text": "a"
},
{
"type": "html",
"raw": "<sub>",
"inLink": false,
"inRawBlock": false,
"block": false,
"text": "<sub>"
},
{
"type": "text",
"raw": "1",
"text": "1"
},
{
"type": "html",
"raw": "</sub>",
"inLink": false,
"inRawBlock": false,
"block": false,
"text": "</sub>"
}
]
After Patching
[
{
"type": "text",
"raw": "a",
"text": "a"
},
{
"type": "html",
"raw": "<sub>",
"inLink": false,
"inRawBlock": false,
"block": false,
"text": "<sub>1</sub>" // the 3 tokens were joined into this one
}
]
As described in the docs:
A way to solve this is to do a single-pass walk along tokens and then join tokens between the outmost html tokens.
For example:
Input Markdown
Ideal Result
a1
Tokens
[ { "type": "text", "raw": "a", "text": "a" }, { "type": "html", "raw": "<sub>", "inLink": false, "inRawBlock": false, "block": false, "text": "<sub>" }, { "type": "text", "raw": "1", "text": "1" }, { "type": "html", "raw": "</sub>", "inLink": false, "inRawBlock": false, "block": false, "text": "</sub>" } ]After Patching
[ { "type": "text", "raw": "a", "text": "a" }, { "type": "html", "raw": "<sub>", "inLink": false, "inRawBlock": false, "block": false, "text": "<sub>1</sub>" // the 3 tokens were joined into this one } ]