Discourse doesn't follow the CommonMark spec for HTML <pre> tags inside code spans

The CommonMark spec states:

Code spans, HTML tags, and autolinks have the same precedence. Thus, this is code:

Input:

`<a href="`">`

Render:

<p><code>&lt;a href=&quot;</code>&quot;&gt;`</p>

The problem is that this doesn’t work for <pre> tags when any part of the input markdown following the code span contains preformatted text. (Example shown in my reply to this post.)

1 Like
This is the `<pre>` tag.

Results in:

This is the <pre> tag.

When any following part of the document contains preformatted text:

This is   pre-formatted text.
This is     pre-formatted text.

This issue does not occur when the document contains pre-formatted text before the code span containing <pre>, or when the document does not contain pre-formatted text at all.

Discourse isn’t on CommonMark yet. It does pass MDTest 1.2 though.

edit: This might still be a bug though that isn’t CM specific, will look into it!

Right. The only reason I mentioned CommonMark is that it’s the only standard I can point to which explains the correct behavior.

Really though the current behavior of Discourse in this area is less than optimal regardless of whether you’re following CommonMark.

This is now all fixed see:

Can not repro any of the issues, also we stopped hoisting code blocks so this can not happen anymore.

4 Likes