diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-10 20:47:23 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-10 21:19:50 +0100 |
| commit | a9fdff244aef859449a76e5f762ee7c343a8ddcc (patch) | |
| tree | 172b543183296b4bc30b3008650f594688467914 /library/src/text | |
| parent | 62f35602a87574dcc607f1637aeae1be574981ff (diff) | |
Expose content representation more
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/deco.rs | 6 | ||||
| -rw-r--r-- | library/src/text/misc.rs | 4 | ||||
| -rw-r--r-- | library/src/text/raw.rs | 15 | ||||
| -rw-r--r-- | library/src/text/shift.rs | 14 |
4 files changed, 12 insertions, 27 deletions
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<Content> { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<Content> { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<Content> { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<Content> { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<Content> { + fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> { 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<Content> { - this.push_field("lang", self.lang(styles).clone()); - Ok(this) + fn prepare(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { + 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<Content> { + fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<synt::Theme> = 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<Content> { + fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> { 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<Content> { + fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> { let body = self.body(); let mut transformed = None; if self.typographic(styles) { |
