24

The GitHub markdown code:

1. First item
* subitem
1. Second item

Generates a big space between the First, Second and the subitem:

enter image description here

How to make the subitem close to the first item, instead of exactly on the middle of them?

This is a Photoshop I did to illustrate the correct output:

enter image description here


Related questions:

  1. Multi paragraph list items, OR preventing numbered list auto formatting
  2. Markdown: Problems with numbered list paragraphs containing code element
Evandro Coan
  • 8,560
  • 11
  • 83
  • 144
  • 1
    I believe the extra space is a mere artifact of the way Github's markdown rendering engine chooses to display it, and there's not much you can do about it. Other markdown engines may display it differently. – frozen Jul 14 '17 at 23:59

3 Answers3

22

You need to indent the sublist with at least 4 spaces:

1. First item
    * subitem
2. Second item
Joao Delgado
  • 861
  • 4
  • 12
4

You cannot do this going from a primary to secondary item. It is possible from a secondary to tertiary list, however. This is due to GitHub's styling of the markdown, not an inherent issue with the markdown itself.

See this document for details on what is possible regarding different layout styles.

Software2
  • 2,358
  • 1
  • 18
  • 28
0

An admittably "hacky" but still working solution:

  1. Choose any character from here.
  2. Copy it and paste it as bullet point:
1. First item  [< two spaces for the linebreak]
◦ subitem1  [< two spaces for the linebreak]
◦ subitem2
2. Second item
  1. Don't forget the two spaces for the linebreak.
  • This works in the sense that there is no extra line added between the first item and the subitem, but if (like mine) your editor auto-removes trailing whitespace, you'll have to manually insert
    everywhere. Tried it, source text became ugly, went back to having an extra line and a readable readme even when not formated. Also, you'll lose indentation.
    – Neven V. May 12 '20 at 07:22
  • 1
    Two spaces serve as a newline which is not required in list environment. – puravidaso Jan 18 '21 at 18:28