mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
53 stars 0 forks source link

decode-elements with decode-paragraphs inserts spurious <p> when nesting lists? #115

Open bluebear94 opened 2 years ago

bluebear94 commented 2 years ago

As in this example:

> (decode-elements
    '("Things to buy" "\n\n" (ol (li "Food" (ul (li "Milk") (li "Eggs") (li "Broccoli")))))
    #:txexpr-elements-proc decode-paragraphs)
'((p "Things to buy")
  (ol (li (p "Food") (ul (li "Milk") (li "Eggs") (li "Broccoli")))))

The <p> tag wrapped around Food doesn't need to be here. Fixing this behavior doesn't sound trivial, though.

mbutterick commented 2 years ago

The result is a little surprising, but it’s consistent with the documented behavior. "Food" is adjacent to a block-txexpr, namely ul, so it gets a p tag. There are different ways you could solve this. Adding #:force? #t to decode-paragraphs will make it consistent.

jnboehm commented 2 years ago

One quick and dirty option to circumvent your problem is removing ul and ol from the block-tags list. Of course that will then turn the behavior off everywhere, but I have found that it doesn't really casue issues for me (yet).

(module setup racket/base
 (provide (all-defined-out))
 (require pollen/setup)
 ;; treat lists as run-in text
 (define block-tags (remq 'ol (remq 'ul default-block-tags))))