Markdown code blocks not formatted correctly

I’ve got an odd behavior with Markdown code blocks. I’m using classHighlightStyle with

HighlightStyle.define([
    { tag: tags.monospace, class: 'cmt-monospace' },
    { tag: tags.quote, class: 'cmt-quote' },
])

Inline code like

This is some random `code`

works fine and results in

<div class="cm-line">
    This is some random
    <span class="cmt-monospace cmt-meta">`</span>
    <span class="cmt-monospace">code</span>
    <span class="cmt-monospace cmt-meta">`</span>
</div>

However, if I specify a code block using 4 spaces as indentation:

    I am a line of code.
    And I am another one.

this results in

<div class="cm-line">    I am a line of code.</div>
<div class="cm-line"><span class="cmt-monospace">    </span>And I am another one.</div>

So only the four leading spaces of line two are assigned the cmt-monospace class.

I’d expect something like this:

<div class="cm-line">
    <span class="cmt-monospace cmt-meta">    </span>
    <span class="cmt-monospace">I am a line of code.</span>
</div>
<div class="cm-line">
    <span class="cmt-monospace cmt-meta">    </span>
    <span class="cmt-monospace">And I am another one.</span>
</div>

Code blocks starting and ending with ``` aren’t highlighted, either.

Yeah, that was broken. This patch should help.

1 Like

Can confirm. Works like a charm, now. Thanks for the great support!