Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text after the end of a nested list doesn't align properly

For example, this

1. first item
2. second item
    - first subitem
    - second subitem
   more info about the 2nd item
3. third item

produces this

enter image description here

How do I get "more info about the 2nd item" to appear where it does in the code?

like image 418
Ben Avatar asked May 04 '17 03:05

Ben


2 Answers

The following places "more info" as an independant paragraph inside the second subitem bullet point, in pandoc markdown.

1. first item
2. second item
    - first subitem
    - second subitem

        more info about the 2nd item

3. third item

Output:

<ol style="list-style-type: decimal">
<li>first item</li>
<li>second item
<ul>
<li>first subitem</li>
<li><p>second subitem</p>
<p>more info about the 2nd item</p></li>
</ul></li>
<li>third item</li>
</ol>
like image 101
scoa Avatar answered Oct 16 '22 11:10

scoa


This is a nasty problem which I also cannot seem to solve in an elegant way. However, for compilation to HTML there is a simple workaround: place a </ul> or </ol> tag after the last item of your nested list.

1. first item
2. second item
    - first subitem
    - second subitem</ul>
   more info about the 2nd item
3. third item

This will trigger the HTML to end the - in this case unordered - nested list before Markdown instructs it to. Luckily, this doesn't break your layout at all, as long as you are mixing unordered (<ul>) and ordered (<ol>) lists. If your nested list is of the same type as its parent this will break your layout*.

If so desired, you can also place a <br> element before the first line that does not belong to the nested list anymore, which I find to produce a more visually appealing layout.

like image 38
PDiracDelta Avatar answered Oct 16 '22 09:10

PDiracDelta