Code-fence and <pre> formatting require preceding blank lines to render correctly in cooked


(PJH) #1

Continuing the discussion from Hyperlinking email addresses in monospaced formatted text:

From the linked topic:

Cooked and preview seem to be having a disagreement about something (preview was my intended/preferred layout, with the CRLF’s):


HTML not escaped in topic titles on /my/activity/posts
Hyperlinking email addresses in monospaced formatted text
(Jeff Atwood) #2

@sam is this related to your recent changes to enable the <table> hack?

Let’s see

This should
be on three
different lines

and with backticks

This should
be on three
different lines

Nope that’s not it, i guess it has to do with URLs?

http://example.com/1
http://example.com/2
http://example.com/3

and with backticks

http://example.com/1
http://example.com/2
http://example.com/3

Nope that’s not it maybe it has to do with HTML style hyperlinks?

<a href="http://example.com/1">one</a>
<a href="http://example.com/2">two</a>
<a href="http://example.com/3">three</a>

and with backticks

<a href="http://example.com/1">one</a>
<a href="http://example.com/2">two</a>
<a href="http://example.com/3">three</a>

Nope all looks fine…

I’m kind of unclear what the repro is here @pjh?


(PJH) #3

Replacing mailto with http:


`­`­` (code fence):

<a href="http://a.example.com">a.example.com</a>
<a href="http://b.example.com">b.example.com</a>
<a href="http://c.example.com">c.example.com</a>

<pre>:

a.example.com
b.example.com
c.example.com

(PJH) #4

Preview (bottom right) is what I’d expect.

Cooked (top center) is what I’d not.


(Jeff Atwood) #5

I think this is because the URLs match the link text. That’s my hunch? Let’s try:

<a href="http://example.com/one">http://example.com/one</a>
<a href="http://example.com/two">http://example.com/two</a>
<a href="http://example.com/three">http://example.com/three</a>
<a href="http://example.com/one">http://example.com/one</a>
<a href="http://example.com/two">http://example.com/two</a>
<a href="http://example.com/three">http://example.com/three</a>

(PJH) #6

Sorry - Instead of copying #3 and replacing mailto: with http:// to see if that was the issue, I ended up editing #3.

Seems to not matter anyway…


(PJH) #7

Nope:

`­`­` (code fence):

<a href="http://a.example.com">http://a.example.com</a>
<a href="http://b.example.com">http://b.example.com</a>
<a href="http://c.example.com">http://c.example.com</a>

<pre>:

http://a.example.com
http://b.example.com
http://c.example.com

<code>:

http://a.example.com
http://b.example.com
http://c.example.com


(PJH) #8

No idea what the differences are…

Copy/paste from raw of yours:

<a href="http://example.com/one">http://example.com/one</a>
<a href="http://example.com/two">http://example.com/two</a>
<a href="http://example.com/three">http://example.com/three</a>
<a href="http://example.com/one">http://example.com/one</a>
<a href="http://example.com/two">http://example.com/two</a>
<a href="http://example.com/three">http://example.com/three</a>

From mine:

`­`­` (code fence):

<a href="http://a.example.com">http://a.example.com</a>
<a href="http://b.example.com">http://b.example.com</a>
<a href="http://c.example.com">http://c.example.com</a>

From mine with extra CRLF:

`­`­` (code fence):

<a href="http://a.example.com">http://a.example.com</a>
<a href="http://b.example.com">http://b.example.com</a>
<a href="http://c.example.com">http://c.example.com</a>

(PJH) #9

Ah. There it is. Those are the only two that require an extra line feed between the previous line and start of markup to make cooked match preview.


(Jeff Atwood) #10

So backtick code blocks require a blank line above them, otherwise they don’t respect linebreaks as expected. Is that it then? If so can you edit the title to reflect?


(PJH) #11

It appears so.

Done.


(Sam Saffron) #12

this

is
now
   fixed
   yay
<pre>
   except 
   that 
   a
   pre
   in a code block is messed up... but I can fix that as well 
</pre>

https://github.com/discourse/discourse/commit/568adc49c09c4964ef3168dfd1fa12c2fb05203b

Fixed pre in block hoisting, but lots of ways to hoist code, so probably a few edge cases left


(Sam Saffron) #13