# Syntax highlighting seems to be not working inside a list

**URL:** https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452
**Category:** Bug
**Tags:** markdown
**Created:** [6월 25, 2015, 3:43오후 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452 "2015-06-25T15:43:21Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [6월 25, 2015, 3:43오후 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/1 "2015-06-25T15:43:21Z")

</div>

### This is works (outside of a list, 3 back-ticks syntax):

```javascript
var s = "JavaScript syntax highlighting";
alert(s);

```

### This is not works (a code block inside a list, 3 back-ticks syntax):

1. List item 1

2. List item 2

3. List item 3

### This is works (a code block inside a list with 4 spaces syntax but without highlighting):

1. List item 1

2. List item 2

3. List item 3

So, is it a bug or I have missed something?  
How to do syntax highlighting inside a list?

---

<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: [6월 26, 2015, 1:36오전 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/2 "2015-06-26T01:36:20Z")

</div>

Not sure that is possible, to get stuff in a list it must be indented. I suggest trying this on GitHub or the CommonMark tester.

Another difficulty is that this three backticks code block style is an addition to Markdown, although it is included in CommonMark, not all markdown flavors will support it.

---

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [6월 26, 2015, 2:51오전 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/3 "2015-06-26T02:51:31Z")

</div>

This is definitely working on GitHub: [http://stackoverflow.com/a/6236145/6309 · GitHub](https://gist.github.com/VonC/10666727#comment-1211206)  
But is not working on a Discourse page…

---

<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: [6월 26, 2015, 2:52오전 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/4 "2015-06-26T02:52:29Z")

</div>

Does it work in the CommonMark tester?

---

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [6월 26, 2015, 3:38오전 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/5 "2015-06-26T03:38:35Z")

</div>

- My code from the first post **[works](http://spec.commonmark.org/dingus/?text=%23%23%23%20This%20is%20works%20%28outside%20of%20a%20list%2C%203%20back-ticks%20syntax%29%3A%0A%60%60%60javascript%0Avar%20s%20%3D%20%22JavaScript%20syntax%20highlighting%22%3B%0Aalert%28s%29%3B%0A%60%60%60%0A%0A%23%23%23%20This%20is%20not%20works%20%28a%20code%20block%20inside%20a%20list%2C%203%20back-ticks%20syntax%29%3A%0A%0A1.%20List%20item%201%0A%20%20%20%20%0A%20%20%20%20%60%60%60javascript%0A%20%20%20%20var%20s%20%3D%20%22JavaScript%20syntax%20highlighting%22%3B%0A%20%20%20%20alert%28s%29%3B%0A%20%20%20%20%60%60%60%0A1.%20List%20item%202%0A1.%20List%20item%203%0A%0A%23%23%23%20This%20is%20works%20%28a%20code%20block%20inside%20a%20list%20with%204%20spaces%20syntax%20but%20without%20highlighting%29%3A%0A%0A1.%20List%20item%201%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20var%20s%20%3D%20%22JavaScript%20syntax%20highlighting%22%3B%0A%20%20%20%20%20%20%20%20alert%28s%29%3B%0A%0A1.%20List%20item%202%0A1.%20List%20item%203%0A%0ASo%2C%20is%20it%20a%20bug%20or%20I%20have%20missed%20something%3F%20%0AHow%20to%20do%20syntax%20highlighting%20inside%20a%20list%3F)** on CommonMark tester.  
It is correctly idented (but not highlighted because as I see CommonMark does not highlight code at all).  
So there is a clear difference: Discourse breaks my case №2 (3 back-ticks syntax) and CommonMark tester correctly renders it.

- GitHub code from my [post 3](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/3) **[does not work](http://spec.commonmark.org/dingus/?text=1.%20foo%0A%0A%20%20%60%60%60%60python%0Aprint%20%27bar%27%0A%20%20%60%60%60%60%0A%0A%20%20%201.%20sub-foo%0A%0A%20%20%20%20%20%20%60%60%60%60python%0Aprint%20%27sub-bar%27%0A%20%20%20%20%20%20%60%60%60%60%0A%20%0A2.%20Bar)** on CommonMark tester.

---

<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: [6월 26, 2015, 4:11오전 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/6 "2015-06-26T04:11:44Z")

</div>

OK, that is good news, within a year or so we will switch to a CommonMark parser and it will work.

---

<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: [6월 26, 2015, 6:39오후 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/7 "2015-06-26T18:39:23Z")

</div>

1. first item

- Second item

Works for me.

````
 1. first item

    ```
    <html><body>Test <a b="c"> </body></html>
    ```

 - Second item

````

---

<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: [6월 26, 2015, 6:40오후 UTC](https://meta.discourse.org/t/syntax-highlighting-seems-to-be-not-working-inside-a-list/30452/8 "2015-06-26T18:40:41Z")

</div>


