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


(Andrew Meyer) #1

The CommonMark spec states:

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


`<a href="`">`


<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.)

(Andrew Meyer) #2
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.

(Andrew Meyer) #3
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.

(Robin Ward) #4

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!

Discourse and CommonMark
(Andrew Meyer) #5

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.

(Sam Saffron) #6

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.

(Sam Saffron) #7