[kramdown-users] Paragraph in list items

Thomas Leitner t_leitner at gmx.at
Mon Mar 15 15:22:40 EDT 2010

On Mon, 15 Mar 2010 20:33:18 +1000, Shawn Van Ittersum wrote:
> That's seems a bit too magical and unintuitive to me... though I
> don't know what else to suggest.

While re-designing the webgen homepage, I found many cases where I use
non-compact lists and where the output does not look correct because
`p` tags have margins applied. I.e. all but the last item have correct
margins. The problem with styling the last item is that there is no tag
to style since the list item just contains text. And styling all list
items with margins would not allow compact lists...

For example, when someone reads the fragment

    Some para

    * This is an item
    * This is another item
    * This is the third item
    Some para

one assumes that there is not much space in the list when it is
converted to HTML. However, when considering the following fragment

    Some para

    * This is an item

    * This is another item

    * This is the third item
    Some para

it is fair to assume that *all* list items should be wrapped in a `p`

> If you do implement it, be sure to check if the last item's contents
> are already wrapped in a block of some kind.  We wouldn't want a div
> getting wrapped in a p.
> * <div class="highlight">Lorem ipsum ...</div>

This would be no problem considering the current implemenation.

> Zooming out a bit, why do we need paragraphs in list items?  I can
> see the use case for this:
> * First item
>   New paragragh in first item
>   Another new paragraph in first item
> * Second item
> But in that case, only the "new paragraphs" need to be wrapped in p
> tags.  Margin can be added to the list items via CSS or inline
> attributes.

As mentioned above, this would ruin the look of compact lists (or you
would need to add a class to each compact list which isn't nice either).

> I'll admit that requiring CSS to add margin when the current behavior
> already adds margin simply via p tags seems, well, a bit ridiculous.
> But to assume that the last item should be a p tag just because the
> others are seems like a path to unintended consequences.

The thing is: you *may* add margins to non-compact lists but you *need
not* since styling a `p` tag directly beneath a `li` tag can easily be

    li > p:first-child {
      margin: 0;
      padding: 0;

-- Thomas

More information about the kramdown-users mailing list