GitbookIO / markup-it

JavaScript library to parse and serialize markup content (Markdown and HTML)
270 stars 49 forks source link

Markdown: Fix serialization/deserialization of inline code with marks #136

Closed jpreynat closed 5 years ago

jpreynat commented 5 years ago

Currently, the serialization of:

<document>
    <paragraph>
        <bold>
            <code>this</code>
        </bold>
        <italic>
            <code>is</code>
        </italic>
        <bold>
            <code>a</code>
        </bold>
        <code>test</code>
    </paragraph>
</document>

leads to the following valid markdown:

**`this`**_`is`_**`a`**`test`

However, deserializing this markdown loses the marks applied around the code and leads to the following document:

<document>
    <paragraph>
        <code>thisisatest</code>
    </paragraph>
</document>

This PR adds tests to ensure that deserializing then serializing to markdown correctly returns the same document and fixes the issue.