Code fences inside a list render as one line

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.

2 Likes

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);
```

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

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

2 Likes

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

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

6 Likes