Jim Danner
Jim Danner

Reputation: 545

Markdown nested list: skip a level

I'm using nested bulleted lists in Markdown. In certain cases, the level must jump from depth 1 to depth 3, as below: HTML-generated nested lists

Can this be done in pure Markdown? (Obviously it can be done in HTML, as above.) The things I try don't work:

* Lowest level
        - Level 3

(with 2x4 spaces before the level 3 bullet) becomes

putting it all into a single line.

* Lowest level  
        - Level 3

(with two spaces at the end of the first line) shows up as

where Level 3 isn't a nested list: it is actually part of the first bullet, which has an internal <br> line break.

* Lowest level
    * 
        * Level 3

again puts all of it into one bullet:

Can it be done?

Upvotes: 4

Views: 740

Answers (2)

Peter Kelley
Peter Kelley

Reputation: 4196

I found the answer at https://commonmark.org/help/tutorial/10-nestedLists.html

To nest one list within another, indent each item in the sublist by four spaces. You can also nest other elements like paragraphs, blockquotes or code blocks.

This worked as expected in my document. I cannot share my data here but the example at the linked tutorial demonstrated the function well. nested lists

Upvotes: 0

glyvox
glyvox

Reputation: 58049

You can achieve this look with fake level 3 items. You can build them up using non-breaking spaces and a ⦁ (Z NOTATION SPOT) character.

Source:

- Lowest level[space][space]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⦁ &nbsp;&nbsp;Level 3: **this skipped level 2**[space][space]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⦁ &nbsp;&nbsp;3 again
    - Level 2
- Back at level 1

Result:

  • Lowest level
              ⦁   Level 3: this skipped level 2
              ⦁   3 again
    • Level 2
  • Back at level 1

For comparison, here's a real list with 3 levels:

  • Level 1
    • Level 2
      • Level 3

Upvotes: 1

Related Questions