# Text missing following fenced code block

**URL:** https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949
**Category:** Bug
**Tags:** markdown-it-review, markdown
**Created:** [September 30, 2015, 3:37pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949 "2015-09-30T15:37:46Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![burke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/burke/32/4211_2.png) [@burke](https://meta.discourse.org/u/burke)
#### Post date: [September 30, 2015, 3:37pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/1 "2015-09-30T15:37:47Z")

</div>

## I was including some text in the last item of a bulleted list and discovered that the text following the code wasn’t rendered by Discourse. &nbsp;

#### Markdown:

````
* Item 1
* Item 2
    ```javascript
    var msg = "Hello world!";
    console.debug(msg);
    ```
    This is hidden

````

#### Rendered:

- Item 1
- Item 2

```javascript
var msg = "Hello world!";
console.debug(msg);

```

This is hidden

* * *

I was expecting that indenting the last line (“This is hidden”) with 4 spaces would allow me to continue the bulleted item with text following the code. While I could surely be doing this wrong, it seemed like a bug that the text was actually omitted (hidden) within my post.

## If the code doesn’t happen to be the last item in the bulletted list, it behaves slightly differently. The text following the code isn’t hidden and the code is no longer syntax-hlighted as expected: &nbsp;

#### Markdown:

````
* Item 1
* Item 2
    ```javascript
    var msg = "Hello world!";
    console.debug(msg);
    ```
    This is not hidden
* Item 3

````

#### Rendered:

- Item 1
- Item 2

```javascript
var msg = "Hello world!";
console.debug(msg);

```

This is not hidden
- Item 3

* * *

That makes me think I just don’t know how to properly embed code within a bulletted list.

Any thoughts? Am I doing this wrong, is there a bug, or is this not yet a feature of Discourse?

Thanks!

-Burke

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [September 30, 2015, 4:22pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/2 "2015-09-30T16:22:32Z")

</div>

Seems like an edge case misuse of MarkDown, but maybe if instead of using the 3 backticks “code block” you used the 1 backtick “inline code” ? (even though it spans more than 1 line)

---

<div class="post-metadata">

### Author: ![burke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/burke/32/4211_2.png) [@burke](https://meta.discourse.org/u/burke)
#### Post date: [September 30, 2015, 8:36pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/3 "2015-09-30T20:36:33Z")

</div>

Thanks for the suggestion. Individual lines is a reasonable workaround, but you lose the syntax highlighting. I guess syntax-highlighting code within a list is asking too much, eh? 😉

The workarounds I’ve come up within (including yours) are:

### Individual lines of code

#### Markdown

```
* Item 1
* Item 2
    `var msg = "Hello world!";`
    `console.debug(msg);`
    This is not hidden

```

#### Rendered:

- Item 1
- Item 2  
`var msg = "Hello world!";`  
`console.debug(msg);`  
This is not hidden

### Code by reference

####Markdown:  
\* Item 1  
\* Item 2  
(Figure 1 below)  
This is not hidden

`````
##### Figure 1:
```javascript
var msg = "Hello world!";
console.debug(msg);
````

`````

#### Rendered:

- Item 1
- Item 2  
(Figure 1 below)  
This is not hidden

##### Figure 1:

```javascript
var msg = "Hello world!";
console.debug(msg);

```

### Code in image

####Markdown:  
\* Item 1  
\* Item 2  
 ![]()  
This is not hidden

#### Rendered:

- Item 1
- Item 2  
 ![](https://global.discourse-cdn.com/meta/original/3X/0/f/0f765d9d3a2f024fe21b01ad743b268da9b2066d.png)  
This is not hidden

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 30, 2015, 8:41pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/4 "2015-09-30T20:41:36Z")

</div>

@eviltrout let’s make sure these all get into the test case suite 😉

---

<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: [September 30, 2015, 10:19pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/5 "2015-09-30T22:19:56Z")

</div>

No you are missing the correct way to do this in Markdown:

- Item 1

- Item 2

- Item 3

Remember **fenced code blocks were never part of the classic Markdown spec** , such as it was…

I don’t think what you want to do is possible without using a “loose” list, versus a “tight” (no spacing) list.

```
- Item 1

    I can type some words here

- Item 2

         var msg = "Hello world!";
         console.debug(msg);

    This is not hidden

- Item 3

```

This is a tight list

- I am
- so close
- to each line

This is a loose list

- I am

- So far apart

- From each line

I always have to remind @sam about the different loose and tight list behaviors since so much is implicit in Markdown. But TL;DR **never mix loose and tight lists**.

---

<div class="post-metadata">

### Author: ![burke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/burke/32/4211_2.png) [@burke](https://meta.discourse.org/u/burke)
#### Post date: [October 1, 2015, 1:12am UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/6 "2015-10-01T01:12:22Z")

</div>

Cool! Thanks for the tip, @codinghorror. It even works with syntax highlighting. 😃

````
* Item 1
                             ← this blank line is important
* Item 2
                             ← this blank line is important
    ```
    var msg = "Hello world!";
    console.log(msg);
    ```
   This text is no longer hidden

````

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;↓

- Item 1

- Item 2

I knew lists could be spaced out (loose), but didn’t appreciate how it could effect formatting.

Thanks!

---

<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: [June 26, 2017, 7:51pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/7 "2017-06-26T19:51:50Z")

</div>

- Item 1
- Item 2

```javascript
var msg = "Hello world!";
console.debug(msg);

```

This is hidden

^^^ Not hidden anymore! 🛬

> [@CommonMark testing started here!](https://meta.discourse.org/t/commonmark-testing-started-here/65121):
>
> Per our [migration plans](https://meta.discourse.org/t/discourse-commonmark-migration-plans-confetti-ball-balloon), I just enabled [markdown.it](https://github.com/markdown-it/markdown-it) at Meta. It is an excellent [CommonMark](http://commonmark.org/) compliant engine. I expect quite a few edges to be found during this period of testing. Do not open bugs about the new Engine, just reply here. I/we will be updating the top post here with the list of issues and striking out stuff as it is fixed. Current known issues (to be fixed)white_check_mark Onebox vanishes after you start typing and works not-super consistently white_check_mark pending…

---

<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: [June 26, 2017, 7:51pm UTC](https://meta.discourse.org/t/text-missing-following-fenced-code-block/33949/8 "2017-06-26T19:51:52Z")

</div>


