Code fences inside a list render as one line

composer

(Clay Heaton) #1

While testing another bug, I posted this text to try.discourse.org:

problem_post.txt (2.5 KB)

The editor preview shows line breaks in the code block, but the post itself renders without the line breaks.


Post won't save (text included)
(Jeff Atwood) #2

This can happens when an invalid language keyword is used, let’s see

line above

size(600, 400);
println("width " + width);
println("height " + height);

versus

line above

size(600, 400);
println("width " + width);
println("height " + height);
line above
``` bleh
size(600, 400);
println("width " + width);
println("height " + height);
```

versus

line above
```
size(600, 400);
println("width " + width);
println("height " + height);
```

(Clay Heaton) #4

The code seems to work fine when it is not nested under a bullet.

  1. Some list

    size(100,100);
    ellipse(x,y,100,100);
    
  2. Another list item

versus…

size(100,100);
ellipse(x,y,100,100);

(John Muhl) #5

It’s the backtick code blocks inside list which are not standardized across implementations (the preview and output differing seems like a real bug though). But you can use indented code blocks as a workaround until Discourse switches to markdown-it (which supports what you are trying to do).

1. first

        size(x, y);
        print(1);

2. second

        size(x, y);
        print(1);

3. third
4. and so on
  1. first

     size(x, y);
     print(1);
    
  2. second

     size(x, y);
     print(1);
    
  3. third

  4. and so on


(Robin Ward) #6

Thanks I’ve fixed this in master (it’s currently being deployed):

https://github.com/discourse/discourse/commit/f2db4bfcf3ee6dc024ef1bee91acf66049753501


(Kane York) #7