I’ve added a bullet list to a writer field, and the HTML output contains paragraphs inserted inside <li>
tags. In Chrome and Firefox this results with text breaking to a new line after a marker. Is there a way to solve this issue?
Currently unsolvable, see Bug: list items contain <p> tags in writer field · Issue #3506 · getkirby/kirby · GitHub
So you would have to remove these tags programmatically at output.
I used this regex code to filter out the <p>
from the <li>
:
<?php
$list = $block->text();
// Remove <p> tags within <li> elements
$list = preg_replace('/<li>\s*<p>(.*?)<\/p>\s*<\/li>/', '<li>$1</li>', $list);
?>
<?= $list; ?>
Note that this snippets needs to be in your snippets/blocks/text.php
if you also using the writer.
2 Likes
I was coming to this same conclusion, thank you for posting