diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-04 22:14:57 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-04 22:14:57 +0200 |
| commit | e674fd7e909c273c36952f01829544a2efc11c92 (patch) | |
| tree | c74218ce4a546de06b28aad2f73ba460338252b7 /src/eval | |
| parent | 75472fee1a2377f56551fc856cf7511bd55091f0 (diff) | |
New raw theme & nicer debug representation
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/func.rs | 10 | ||||
| -rw-r--r-- | src/eval/value.rs | 22 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/eval/func.rs b/src/eval/func.rs index 7e4040b6..b72e9f18 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Debug, Formatter, Write}; +use std::fmt::{self, Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::sync::Arc; @@ -119,12 +119,10 @@ impl Func { impl Debug for Func { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.write_str("<function")?; - if let Some(name) = self.name() { - f.write_char(' ')?; - f.write_str(name)?; + match self.name() { + Some(name) => f.write_str(name), + None => f.write_str("(..) => {..}"), } - f.write_char('>') } } diff --git a/src/eval/value.rs b/src/eval/value.rs index fc54cbce..b5607cfd 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -122,8 +122,9 @@ impl Value { Value::Content(v) => v, // For values which can't be shown "naturally", we return the raw - // representation. - v => Content::show(RawNode { text: v.repr(), block: false }), + // representation with typst code syntax highlighting. + v => Content::show(RawNode { text: v.repr(), block: false }) + .styled(RawNode::LANG, Some("typc".into())), } } } @@ -149,7 +150,7 @@ impl Debug for Value { Self::Fraction(v) => Debug::fmt(v, f), Self::Color(v) => Debug::fmt(v, f), Self::Str(v) => Debug::fmt(v, f), - Self::Content(_) => f.pad("<content>"), + Self::Content(_) => f.pad("[...]"), Self::Array(v) => Debug::fmt(v, f), Self::Dict(v) => Debug::fmt(v, f), Self::Func(v) => Debug::fmt(v, f), @@ -720,7 +721,10 @@ mod tests { "30% + 56.69pt", ); test(Fraction::one() * 7.55, "7.55fr"); - test(Color::Rgba(RgbaColor::new(1, 1, 1, 0xff)), "#010101"); + test( + Color::Rgba(RgbaColor::new(1, 1, 1, 0xff)), + "rgb(\"#010101\")", + ); // Collections. test("hello", r#""hello""#); @@ -734,13 +738,9 @@ mod tests { test(dict!["one" => 1], "(one: 1)"); test(dict!["two" => false, "one" => 1], "(one: 1, two: false)"); - // Functions. - test( - Func::from_fn("nil", |_, _| Ok(Value::None)), - "<function nil>", - ); - - // Dynamics. + // Functions, content and dynamics. + test(Content::Text("a".into()), "[...]"); + test(Func::from_fn("nil", |_, _| Ok(Value::None)), "nil"); test(Dynamic::new(1), "1"); } } |
