Syntax highlighting seems to be not working inside a list

markdown

(Discourse.PRO) #1

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

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

    var s = "JavaScript syntax highlighting";
    alert(s);
    
  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

     var s = "JavaScript syntax highlighting";
     alert(s);
    
  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?


(Jeff Atwood) #2

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.


(Discourse.PRO) #3

This is definitely working on GitHub: http://stackoverflow.com/a/6236145/6309 · GitHub
But is not working on a Discourse page…


(Jeff Atwood) #4

Does it work in the CommonMark tester?


(Discourse.PRO) #5
  • My code from the first post works 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 does not work on CommonMark tester.


(Jeff Atwood) #6

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


(Kane York) #7
  1. first item

    <html><body>Test <a b="c"> </body></html>
    
  • Second item

Works for me.

 1. first item

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

 - Second item

(Kane York) #8