mirror of
https://github.com/typst/typst
synced 2025-08-19 17:38:32 +08:00
Move is_inline
to HtmlElem
(#6748)
This commit is contained in:
parent
57f85eb4fd
commit
a7c8fd6872
@ -125,9 +125,3 @@ fn last_char(nodes: &[HtmlNode]) -> Option<char> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Checks whether the given element is an inline-level HTML element.
|
||||
pub fn is_inline(elem: &Content) -> bool {
|
||||
elem.to_packed::<HtmlElem>()
|
||||
.is_some_and(|elem| tag::is_inline_by_default(elem.tag))
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use typst_library::text::SmartQuoter;
|
||||
use typst_syntax::Span;
|
||||
use typst_utils::NonZeroExt;
|
||||
|
||||
use crate::{HtmlDocument, HtmlElement, HtmlNode, attr, tag};
|
||||
use crate::{HtmlDocument, HtmlElem, HtmlElement, HtmlNode, attr, tag};
|
||||
|
||||
/// Produce an HTML document from content.
|
||||
///
|
||||
@ -72,10 +72,7 @@ fn html_document_impl(
|
||||
let arenas = Arenas::default();
|
||||
let mut info = DocumentInfo::default();
|
||||
let children = (engine.routines.realize)(
|
||||
RealizationKind::HtmlDocument {
|
||||
info: &mut info,
|
||||
is_inline: crate::convert::is_inline,
|
||||
},
|
||||
RealizationKind::HtmlDocument { info: &mut info, is_inline: HtmlElem::is_inline },
|
||||
&mut engine,
|
||||
&mut locator,
|
||||
&arenas,
|
||||
|
@ -9,7 +9,7 @@ use typst_library::World;
|
||||
use typst_library::routines::{Arenas, FragmentKind, Pair, RealizationKind, Routines};
|
||||
use typst_library::text::SmartQuoter;
|
||||
|
||||
use crate::HtmlNode;
|
||||
use crate::{HtmlElem, HtmlNode};
|
||||
|
||||
/// Produces HTML nodes from content contained in an HTML element that is
|
||||
/// block-level by default.
|
||||
@ -114,7 +114,7 @@ fn realize_fragment<'a>(
|
||||
RealizationKind::HtmlFragment {
|
||||
// We ignore the `FragmentKind` because we handle both uniformly.
|
||||
kind: &mut FragmentKind::Block,
|
||||
is_inline: crate::convert::is_inline,
|
||||
is_inline: HtmlElem::is_inline,
|
||||
},
|
||||
engine,
|
||||
locator,
|
||||
|
@ -97,6 +97,12 @@ impl HtmlElem {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks whether the given element is an inline-level HTML element.
|
||||
fn is_inline(elem: &Content) -> bool {
|
||||
elem.to_packed::<HtmlElem>()
|
||||
.is_some_and(|elem| tag::is_inline_by_default(elem.tag))
|
||||
}
|
||||
}
|
||||
|
||||
/// An element that lays out its content as an inline SVG.
|
||||
|
Loading…
x
Reference in New Issue
Block a user