Skip to content

Support inline HTML in markdown blocks #98

Description

@CNSeniorious000

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

a<sub>1</sub>

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
    }
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions