diff options
Diffstat (limited to 'crates/typst-library/src/html/dom.rs')
| -rw-r--r-- | crates/typst-library/src/html/dom.rs | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/crates/typst-library/src/html/dom.rs b/crates/typst-library/src/html/dom.rs index ee94279f..3d558fb0 100644 --- a/crates/typst-library/src/html/dom.rs +++ b/crates/typst-library/src/html/dom.rs @@ -470,6 +470,59 @@ pub mod tag { wbr } + /// Whether nodes with the tag have the CSS property `display: block` by + /// default. + /// + /// If this is true, then pretty-printing can insert spaces around such + /// nodes and around the contents of such nodes. + /// + /// However, when users change the properties of such tags via CSS, the + /// insertion of whitespace may actually impact the visual output; for + /// example, <https://www.w3.org/TR/css-text-3/#example-af2745cd> shows how + /// adding CSS rules to `<p>` can make it sensitive to whitespace. In such + /// cases, users should disable pretty-printing. + pub fn is_block_by_default(tag: HtmlTag) -> bool { + matches!( + tag, + self::html + | self::head + | self::body + | self::article + | self::aside + | self::h1 + | self::h2 + | self::h3 + | self::h4 + | self::h5 + | self::h6 + | self::hgroup + | self::nav + | self::section + | self::dd + | self::dl + | self::dt + | self::menu + | self::ol + | self::ul + | self::address + | self::blockquote + | self::dialog + | self::div + | self::fieldset + | self::figure + | self::figcaption + | self::footer + | self::form + | self::header + | self::hr + | self::legend + | self::main + | self::p + | self::pre + | self::search + ) + } + /// Whether the element is inline-level as opposed to being block-level. /// /// Not sure whether this distinction really makes sense. But we somehow @@ -480,7 +533,7 @@ pub mod tag { /// <https://www.w3.org/TR/html401/struct/global.html#block-inline> /// <https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content> /// <https://github.com/orgs/mdn/discussions/353> - pub fn is_inline(tag: HtmlTag) -> bool { + pub fn is_inline_by_default(tag: HtmlTag) -> bool { matches!( tag, self::abbr |
