Writer field <p> inside <li>

When I use the writer field to create an unordered list and display the content like this:

<?= $page->fieldName()->kt() ?>

The ordered list in the html has nested paragraph tags inside the list elements like this:

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

Because of this the bullets are on a different line than the paragraphs. Is there a way to fix this?

[Kirby v3.7.2.1]

Why do you want to output the writer field with kt()? But this is an issue with the underlying library (prosemirror), I think, even if you don’t use kt().

Oops my bad, without the kt() ofcourse but the problem still remains

See above, nothing we can do about, you would have to remove the p tags via code.

Any recommendations on how to do so? Since there isn’t a fix on your end I figure there are a lot of people running into the same problem?

You would need something that manipulates a chunk of html. This will probably do it:

Or you could make a little custom field method that leans on some of Kirbies built in string helpers, like replace. You should be able to find the P tags and replace them with nothing using that.

1 Like