Strange behaviour of kirbytext() with unordered lists

In a text field that I output with kirbytext() I just noticed a strange behavior:

The text field contains an unordered list in markdown:

- Beisitzer
- Vorsitzender
- Aufsichtsrat

The HTML looks as expected:

<ul>
	<li>Beisitzer</li>
	<li>Vorsitzender </li>
	<li>Aufsichtsrat</li>
</ul>

However, if one of the list items starts with a number, kirbytext() produces a nested list from it.

- Beisitzer
- 1. Vorsitzender
- Aufsichtsrat

The HTML will look like this:

<ul>
	<li>Beisitzer</li>
	<li>
		<ol>
			<li>Vorsitzender</li>
		<ol>
	</li>
	<li>Aufsichtsrat</li>
</ul>

This behavior is driving me crazy right now. On the website in question, there are list items in several places within unordered lists that start with a bullet number. Looks like a bug for me. Has anybody already experienced this behavior and knows a workaround?

That is expected behavior. You have to escapt such characters in Markdown, see Daring Fireball: Markdown Syntax Documentation

1 Like

Sonja, you saved my day – again! Thanks a lot!

- 1\. Vorsitzender

results in a correct list item.

Still, I’m having a bit of a hard time acknowledging this as expected or even helpful behavior right now. Gruber writes “It’s worth noting that it’s possible to trigger an ordered list by accident”

If you use Markdown, this is how it works. If you need a field only for lists, consider the list field.

You have to know it… I write a lot in Markdown, but never stumbled over this in the last >10 years.