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

Open
opened 3 years ago by bluebear94 · 2 comments
bluebear94 commented 3 years ago (Migrated from github.com)

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.

As in this example: ```racket > (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 3 years ago (Migrated from github.com)

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.

The result is a little surprising, but it’s consistent with the [documented behavior](https://docs.racket-lang.org/pollen/Decode.html#%28def._%28%28lib._pollen%2Fdecode..rkt%29._decode-paragraphs%29%29). `"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 3 years ago (Migrated from github.com)

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))))
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). ```racket (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)))) ```
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen-users#115
Loading…
There is no content yet.