From a9fdff244aef859449a76e5f762ee7c343a8ddcc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 10 Mar 2023 20:47:23 +0100 Subject: Expose content representation more --- library/src/text/deco.rs | 6 +++--- library/src/text/misc.rs | 4 ++-- library/src/text/raw.rs | 15 +++++---------- library/src/text/shift.rs | 14 ++------------ 4 files changed, 12 insertions(+), 27 deletions(-) (limited to 'library/src/text') diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index 4dadf45a..27d30286 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -66,7 +66,7 @@ pub struct UnderlineNode { } impl Show for UnderlineNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { Ok(self.body().styled(TextNode::set_deco(Decoration { line: DecoLine::Underline, stroke: self.stroke(styles).unwrap_or_default(), @@ -145,7 +145,7 @@ pub struct OverlineNode { } impl Show for OverlineNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { Ok(self.body().styled(TextNode::set_deco(Decoration { line: DecoLine::Overline, stroke: self.stroke(styles).unwrap_or_default(), @@ -209,7 +209,7 @@ pub struct StrikeNode { } impl Show for StrikeNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { Ok(self.body().styled(TextNode::set_deco(Decoration { line: DecoLine::Strikethrough, stroke: self.stroke(styles).unwrap_or_default(), diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index 60521f12..029e15f4 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -99,7 +99,7 @@ pub struct StrongNode { } impl Show for StrongNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { Ok(self.body().styled(TextNode::set_delta(Delta(self.delta(styles))))) } } @@ -159,7 +159,7 @@ pub struct EmphNode { } impl Show for EmphNode { - fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult { Ok(self.body().styled(TextNode::set_emph(Toggle))) } } diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 3768e65e..72dd1782 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -104,19 +104,15 @@ pub struct RawNode { } impl Prepare for RawNode { - fn prepare( - &self, - _: &mut Vt, - mut this: Content, - styles: StyleChain, - ) -> SourceResult { - this.push_field("lang", self.lang(styles).clone()); - Ok(this) + fn prepare(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { + let mut node = self.clone().pack(); + node.push_field("lang", self.lang(styles).clone()); + Ok(node) } } impl Show for RawNode { - fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult { let text = self.text(); let lang = self.lang(styles).as_ref().map(|s| s.to_lowercase()); let foreground = THEME @@ -279,7 +275,6 @@ pub static THEME: Lazy = Lazy::new(|| synt::Theme { item("support.macro", Some("#16718d"), None), item("meta.annotation", Some("#301414"), None), item("entity.other, meta.interpolation", Some("#8b41b1"), None), - item("invalid", Some("#ff0000"), None), ], }); diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs index acd46d4e..20cfaa49 100644 --- a/library/src/text/shift.rs +++ b/library/src/text/shift.rs @@ -47,12 +47,7 @@ pub struct SubNode { } impl Show for SubNode { - fn show( - &self, - vt: &mut Vt, - _: &Content, - styles: StyleChain, - ) -> SourceResult { + fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult { let body = self.body(); let mut transformed = None; if self.typographic(styles) { @@ -114,12 +109,7 @@ pub struct SuperNode { } impl Show for SuperNode { - fn show( - &self, - vt: &mut Vt, - _: &Content, - styles: StyleChain, - ) -> SourceResult { + fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult { let body = self.body(); let mut transformed = None; if self.typographic(styles) { -- cgit v1.2.3