mirror of
https://github.com/typst/typst
synced 2025-08-20 09:49:02 +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
|
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_syntax::Span;
|
||||||
use typst_utils::NonZeroExt;
|
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.
|
/// Produce an HTML document from content.
|
||||||
///
|
///
|
||||||
@ -72,10 +72,7 @@ fn html_document_impl(
|
|||||||
let arenas = Arenas::default();
|
let arenas = Arenas::default();
|
||||||
let mut info = DocumentInfo::default();
|
let mut info = DocumentInfo::default();
|
||||||
let children = (engine.routines.realize)(
|
let children = (engine.routines.realize)(
|
||||||
RealizationKind::HtmlDocument {
|
RealizationKind::HtmlDocument { info: &mut info, is_inline: HtmlElem::is_inline },
|
||||||
info: &mut info,
|
|
||||||
is_inline: crate::convert::is_inline,
|
|
||||||
},
|
|
||||||
&mut engine,
|
&mut engine,
|
||||||
&mut locator,
|
&mut locator,
|
||||||
&arenas,
|
&arenas,
|
||||||
|
@ -9,7 +9,7 @@ use typst_library::World;
|
|||||||
use typst_library::routines::{Arenas, FragmentKind, Pair, RealizationKind, Routines};
|
use typst_library::routines::{Arenas, FragmentKind, Pair, RealizationKind, Routines};
|
||||||
use typst_library::text::SmartQuoter;
|
use typst_library::text::SmartQuoter;
|
||||||
|
|
||||||
use crate::HtmlNode;
|
use crate::{HtmlElem, HtmlNode};
|
||||||
|
|
||||||
/// Produces HTML nodes from content contained in an HTML element that is
|
/// Produces HTML nodes from content contained in an HTML element that is
|
||||||
/// block-level by default.
|
/// block-level by default.
|
||||||
@ -114,7 +114,7 @@ fn realize_fragment<'a>(
|
|||||||
RealizationKind::HtmlFragment {
|
RealizationKind::HtmlFragment {
|
||||||
// We ignore the `FragmentKind` because we handle both uniformly.
|
// We ignore the `FragmentKind` because we handle both uniformly.
|
||||||
kind: &mut FragmentKind::Block,
|
kind: &mut FragmentKind::Block,
|
||||||
is_inline: crate::convert::is_inline,
|
is_inline: HtmlElem::is_inline,
|
||||||
},
|
},
|
||||||
engine,
|
engine,
|
||||||
locator,
|
locator,
|
||||||
|
@ -97,6 +97,12 @@ impl HtmlElem {
|
|||||||
self
|
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.
|
/// An element that lays out its content as an inline SVG.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user