From 989d170dc7318ca3cbaa5b76760eb14f4e6a8605 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 28 Nov 2022 12:40:16 +0100 Subject: Fragments --- library/src/math/mod.rs | 10 ++++++---- library/src/math/tex.rs | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'library/src/math') diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 3b1d66e9..7136c8b9 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -19,7 +19,7 @@ pub struct MathNode { pub display: bool, } -#[node(Show, LayoutInline, Texify)] +#[node(Show, Layout, Inline, Texify)] impl MathNode { fn field(&self, name: &str) -> Option { match name { @@ -48,17 +48,19 @@ impl Show for MathNode { } } -impl LayoutInline for MathNode { - fn layout_inline( +impl Layout for MathNode { + fn layout( &self, world: Tracked, styles: StyleChain, _: &Regions, - ) -> SourceResult { + ) -> SourceResult { layout_tex(world, &self.texify(), self.display, styles) } } +impl Inline for MathNode {} + impl Texify for MathNode { fn texify(&self) -> EcoString { self.children.iter().map(Texify::texify).collect() diff --git a/library/src/math/tex.rs b/library/src/math/tex.rs index a85bab18..5f332f3c 100644 --- a/library/src/math/tex.rs +++ b/library/src/math/tex.rs @@ -39,7 +39,7 @@ pub fn layout_tex( tex: &str, display: bool, styles: StyleChain, -) -> SourceResult { +) -> SourceResult { // Load the font. let variant = variant(styles); let mut font = None; @@ -98,7 +98,8 @@ pub fn layout_tex( // Render into the frame. renderer.render(&layout, &mut backend); - Ok(backend.frame) + + Ok(Fragment::frame(backend.frame)) } /// A ReX rendering backend that renders into a frame. -- cgit v1.2.3