Markdown two seperate lists

so I have this markdown:

### Öffnungszeiten

- Montag bis Sonntag ab 18 Uhr
- Küchenschluss um 22 Uhr

- 24.12. bis 26.12. & 31.12.  von 18 bis 22 Uhr

it generates

  <li>Montag bis Sonntag ab 18 Uhr</li>
    <p>Küchenschluss um 22 Uhr</p>
  <li>24.12. bis 26.12. &amp; 31.12. von 18 bis 22 Uhr</li>

what I expected:

  <li>Montag bis Sonntag ab 18 Uhr</li>
  <li>Küchenschluss um 22 Uhr</li>
  <li>24.12. bis 26.12. &amp; 31.12. von 18 bis 22 Uhr</li>

is it supposed to be like that ? or is there an issue with the markdown parsing ?

Yes, I can reproduce this. But not sure if this is a bug or a feature.

In your example, I would put a new headline in between the two lists, anyway, something like “Öffnungszeiten zwischen den Jahren”.

You can also use a comment tag as a workaround.

This is how markdown is designed to work.

The whitespace after your second bullet point means “wrap the preceding list item in a <p> tag”.

This probably isn’t what you expected, but it’s how Markdown works.

I would argue that it’s the lack of design, that makes this happen in markdown. But I see it’s an issue with the Markdown Library and not with Kirby.

BTW playin around with PHP Markdown Dingus

- list 1
- list 1

* list 2
* list 2


  <li>list 1</li>
  <li><p>list 1</p></li>
  <li><p>list 2</p></li>
  <li>list 2</li>

I’m happy to hear the design reason in the second <p>

It probably does not know where the <p> tag belongs. But anyway, I would argue that it does not make sense from a semantic point of view to have multiple lists without any text in between.

you are probably right. But thank you all for your input :slight_smile:

This is where it gets interesting.

Paste that same markdown into this page, and you’ll see that different markdown parsers actually handle it differently.

Parsedown (the one of the right) is the parser that Kirby uses. It only wraps the second list item in a <p> tag, whereas Markdown PHP 1.3 wraps both the second and third list items in a <p> tag.

Unfortunately, the creator of Markdown didn’t describe this use case in much detail, leaving the interpretation of the syntax up to each individual parser:

If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output.

At the end of the day, it looks like Markdown just doesn’t handle consecutive lists.

1 Like

At the end of the day, you have the following options:

  • do not use consecutive lists, but put some text in between
  • enable markdown.extra and put the list items between <ul markdown=1> tags
  • use comments to separate the lists
  • add a different markdown parser component (if you find one that works for this use case)