How do I control when the HTML export produces <p> tags? (Specifically, for customising lists)

I’m struggling to add a class attribute to a list when rendering to HTML. I’ve boiled the problem down to the fact that, no matter what I do, it produces <p> tags in between my <li> tags.

Here’s a minimal example which just tries to make a plain <ul> element with two items:

#html.ul(
  (html.li("a"), html.li("b")).join("")
)

That produces this HTML:

<ul>
      <li>a</li>
      <p></p>
      <li>b</li>
</ul>

I’ve found another thread about why Typst decides to wrap things in <p> tags, but I can’t see what I need to change here.

Are lists special?

Call the join method without the argument.

1 Like

ahh, thank you! So it’s the empty string that’s getting wrapped in a paragraph tag, because it’s between two elements? I can sort of see the logic there.

1 Like

You are creating empty string, which is empty content, which is wrapped in p in HTML. Which will be in between each adjacent pair of elements in the array. Same as array.intersperse("").join(). In practice, argument is always omitted, but is passed for concatenating strings or inline content.