# Line breaks in code blocks don't work without a linebreak above

**URL:** https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555
**Category:** Bug
**Created:** [2015 年 7 月 30 日午前 8:28 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555 "2015-07-30T08:28:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2015 年 7 月 30 日午前 8:28 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/1 "2015-07-30T08:28:53Z")

</div>

I have a few code blocks inside lists in my [“Importing from phpBB3” topic](https://meta.discourse.org/t/importing-from-phpbb3/30810/1). They looked fine when I posted this a few days ago. But now, after a small edit with insignificant changes, the line breaks inside the code blocks are gone.

The preview still looks fine:  
 ![](https://global.discourse-cdn.com/meta/original/3X/b/d/bd8e166bdb3d79b300404e7ae89f9d05949a2234.png)

The actual post however looks wrong:  
 ![](https://global.discourse-cdn.com/meta/original/3X/3/6/362ddc188fbc69ca8b73640b39c2d42dc3ea3d0c.png)

Is this a regression or is there something wrong with my post?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2015 年 7 月 30 日午前 9:05 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/2 "2015-07-30T09:05:58Z")

</div>

Something’s wrong here. Will have a look.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2015 年 7 月 30 日午前 10:02 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/3 "2015-07-30T10:02:11Z")

</div>

Has already been reported. You need a blank line above or that will happen.

You also really ought to use 4 space indent rather than fenced code blocks when you don’t need syntax highlighting.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2015 年 7 月 30 日午前 10:04 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/4 "2015-07-30T10:04:31Z")

</div>

The strange thing is, it worked when I posted it two weeks ago…

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2015 年 7 月 30 日午前 10:04 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/5 "2015-07-30T10:04:53Z")

</div>

Could be related to @sam’s changes to hack in `<table>` support, don’t know.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2015 年 7 月 30 日午前 10:09 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/6 "2015-07-30T10:09:01Z")

</div>

Ok, I changed the way I format the code blocks for now. The thing is, I kinda like the bash syntax highlighting. 😉

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2015 年 7 月 30 日午前 10:21 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/7 "2015-07-30T10:21:30Z")

</div>

The issue here really is why is the preview different than the cooked post?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015 年 7 月 31 日午前 8:19 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/8 "2015-07-31T08:19:43Z")

</div>

I have a hunch on this.

We never _correctly_

```plaintext
hoisted
code blocks

```

and this incorrect hoisting, though not impacting the client that uses ember initializers to initialize dialects, did heavily impact the server that uses a different paradigm.

I fixed hoisting and unhoisting… but our architecture needs some TLC here, we need to split off the rendering engine into a cleaner, independent, multisite friendly piece.

[https://github.com/discourse/discourse/commit/568adc49c09c4964ef3168dfd1fa12c2fb05203b](https://github.com/discourse/discourse/commit/568adc49c09c4964ef3168dfd1fa12c2fb05203b)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015 年 7 月 31 日午前 8:20 UTC](https://meta.discourse.org/t/line-breaks-in-code-blocks-dont-work-without-a-linebreak-above/31555/9 "2015-07-31T08:20:00Z")

</div>


