<p> tags adding to <li> in Writer field

When I add an OL or UL using the Writer field, it automatically adds

tags in between the

  • tags like shown below. Is there a way to stop this?

    <ul>
      <li><p>Listitem</p></li>
      <li><p>Listitem</p></li>
    </ul>
    
  • This is a known Prosemirror issue: Bug: list items contain <p> tags in writer field · Issue #3506 · getkirby/kirby · GitHub

    If you want to get rid of the p tags, you would have to filter them out at render time.

    How do I do this just for a list-item?

    Replace the patterns <li><p> with <li> and </p></li> with </li>

    https://www.php.net/manual/de/function.preg-replace.php

    Is this one still unsolved? At least to me it’s a big issue because it brings wrong semantics.

    Looks like it

    1 Like

    It’s a feature, not a bug!

    The intended behaviour for lists, in John Gruber’s original Markdown syntax:

    “If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output”
    — from John Gruber’s original docs (Daring Fireball: Markdown Syntax Documentation)

    So, to prevent unwanted <p> tags, you just need to avoid blank lines between list items in your markup.

    As far as I know this behaviour is adhered-to in Commonmark, GitHub-flavoured Markdown, ProseMirror (used I think in Kirby’s Writer field), and Parsedown (used in Kirby’s original Markdown field). The latter responds to a single blank line in the list markup, but ProseMirror seems to require a blank line between every list item.

    I accidentally discovered this feature months after first using Markdown, and it still seems surprisingly little known, or used. But it’s a terrific feature that enables us to target lists in Markdown with two completely separate stylings.

    I’ve written enthusiastically about this in my personal blog at: A sample post with everything in it, at brianliddell.com , including examples of how it can be used.

    I hope this answers your question, and that I’ve not made any mistakes!