Add source tag to default block-tags #120

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

I noticed that the <source> tag is not treated as a block level element. While it strictly speaking doesn't really denote a block element, I think it would be better as it's required that a source element is a direct descendant of a picture or video element. The current behavior will wrap a paragraph around <source>, thus breaking that assumption.

I'd almost consider it a bug, but would be open to discussion, whether the current behavior makes sense.

The current workaround is to add it to the list manually, but I think having it as a block tag would be generally more useful than not.

I noticed that the [`<source>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) tag is not treated as a block level element. While it strictly speaking doesn't really denote a block element, I think it would be better as it's required that a source element is a direct descendant of a picture or video element. The current behavior will wrap a paragraph around `<source>`, thus breaking that assumption. I'd almost consider it a bug, but would be open to discussion, whether the current behavior makes sense. The current workaround is to add it to the list manually, but I think having it as a block tag would be generally more useful than not.
otherjoel commented 2 years ago (Migrated from github.com)

Can you provide a minimal example? By “the current behavior” are you talking about the behavior of decode-paragraphs?

#lang racket

(require pollen/decode)

(decode-paragraphs '("Hello" (video [[width "250"] [height "200"]]
                                    (source "h.mp4")
                                    (source "h.webm")
                                    "This browser does not support the HTML5 video element.")
                             "there"))

produces

'((p "Hello")
  (video
   ((width "250") (height "200"))
   (source "h.mp4")
   (source "h.webm")
   "This browser does not support the HTML5 video element.")
  (p "there"))
Can you provide a minimal example? By “the current behavior” are you talking about the behavior of `decode-paragraphs`? ```racket #lang racket (require pollen/decode) (decode-paragraphs '("Hello" (video [[width "250"] [height "200"]] (source "h.mp4") (source "h.webm") "This browser does not support the HTML5 video element.") "there")) ``` produces ``` '((p "Hello") (video ((width "250") (height "200")) (source "h.mp4") (source "h.webm") "This browser does not support the HTML5 video element.") (p "there")) ```
jnboehm commented 2 years ago (Migrated from github.com)

Thanks for the response! Actually, I cannot reproduce that behavior, I just noticed it at some point and chalked it up to the tag not being present in block-tags. Now I am thinking that I could have been writing the markup in a pollen file directly and inserted a double newline.

I did remove the source tag from my block-tags and it still works as before; so I guess that makes my proposition obsolete.

Thanks again and sorry for the noise!

Thanks for the response! Actually, I cannot reproduce that behavior, I just noticed it at some point and chalked it up to the tag not being present in `block-tags`. Now I am thinking that I could have been writing the markup in a pollen file directly and inserted a double newline. I did remove the `source` tag from my `block-tags` and it still works as before; so I guess that makes my proposition obsolete. Thanks again and sorry for the noise!
jnboehm commented 2 years ago (Migrated from github.com)

I figured out how I got into that situation: I also added img to the default block-tags. That caused the sources to be interpreted as text running in front. My txexpr looked like:

'(picture
  (source ((srcset "a.webp")))
  (source ((srcset "b")))
  (img ((src "c"))))

I personally think that both would fit into the block-tag category (and would have thought that they are in there), but I understand that it's not the case when looking at what's a block-level element according to MDN.

I figured out how I got into that situation: I also added `img` to the default `block-tags`. That caused the `source`s to be interpreted as text running in front. My txexpr looked like: ```racket '(picture (source ((srcset "a.webp"))) (source ((srcset "b"))) (img ((src "c")))) ``` I personally think that both would fit into the `block-tag` category (and would have thought that they are in there), but I understand that it's not the case when looking at what's a block-level element according to [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
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#120
Loading…
There is no content yet.