Code blocks nested inside of lists do not work

Issue #19 new
Ben Nugent created an issue

I'm unable to nest a multi-line code block inside of a list. The code all appears on one line. Example:

  1. Item One

    Code line 1 Code line 2

  2. Item Two

Comments (12)

  1. Craine Runton

    I struggled with this as well earlier this month. What I found was that you have to use indented code blocks, not blocks delineated by ticks marks. So in order to get a multi-line code block nested within a list, such as:


    GET

    Retrieve the user's account info

    • Request

      • Headers
        Accept: application/json  
        X-LTC-User-ID: {stored user ID}  
        X-LTC-API-Key: {stored user API key}
        
    • Response 200 (application/json)

      • Headers

        Content-Type: application/json
        
      • Body


    You'll have to put 8 spaces in front of the code block, in addition to the indentation for whatever list level you want it to work on, like so (spaces represented by periods here):

    #### GET  
    Retrieve the user's account info
    
    + Request
    
    ....+ Headers    
    \n
    ............Accept: application/json  
    ............X-LTC-User-ID: {stored user ID}  
    ............X-LTC-API-Key: {stored user API key}
    \n
    + Response 200 (application/json)
    
    ....+ Headers  
    \n
    ............Content-Type: application/json  
    \n
    ....+ Body
    

    I also found that you have to have the newlines before & after the indented code block, otherwise it will end up as a regular paragraph under that list level. The biggest problem that I've found with this implementation is that you cannot use the spiffy syntax highlighting with indented code blocks, but otherwise they do work.

  2. George Hategan

    In latest as of today cloud version of bitbucket (6.2) the problem still exists however I can use triple backticks as long as I leave an empty line before and after the code block.

  3. Michael Nielsen

    Bitbucket your markdown rendering is broken. Would you kindly fix it?

    I cannot get code blocks that are part of a list element to indent and format properly, although it looks fine in Intellij and renders correctly at [https://dillinger.io/](https://dillinger.io/)

    e.g I need the code block indented under “b”:

    • a

      • b
    {"a": "b"}
    

    This works properly in Intellij and dillinger.io. Why can’t it work properly on bitbucket?

  4. Hajime Sugiuchi

    @Mateusz Łoskot
    Thanks for your post. I was wondering why this was not working.
    I have voted.

  5. Log in to comment