From 89eb8bae49edb71d9a9279a2210bb1ccaf4dd707 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 30 Jan 2021 12:09:26 +0100 Subject: =?UTF-8?q?New=20syntax=20=F0=9F=92=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Everything everywhere! - Blocks with curly braces: {} - Templates with brackets: [] - Function templates with hashtag: `#[f]` - Headings with equals sign: `= Introduction` --- src/eval/value.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/eval') diff --git a/src/eval/value.rs b/src/eval/value.rs index 6e838f6c..860c0634 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -8,7 +8,7 @@ use super::{Args, Eval, EvalContext}; use crate::color::Color; use crate::geom::{Angle, Length, Linear, Relative}; use crate::pretty::{pretty, Pretty, Printer}; -use crate::syntax::{Spanned, Tree, WithSpan}; +use crate::syntax::{pretty_template, Spanned, Tree, WithSpan}; /// A computational value. #[derive(Debug, Clone, PartialEq)] @@ -121,11 +121,7 @@ impl Pretty for Value { Value::Str(v) => write!(p, "{:?}", v).unwrap(), Value::Array(v) => v.pretty(p), Value::Dict(v) => v.pretty(p), - Value::Template(v) => { - p.push_str("["); - v.pretty(p); - p.push_str("]"); - } + Value::Template(v) => pretty_template(v, p), Value::Func(v) => v.pretty(p), Value::Any(v) => v.pretty(p), Value::Error => p.push_str("(error)"), @@ -537,8 +533,8 @@ mod tests { // Dictionary. let mut dict = BTreeMap::new(); dict.insert("one".into(), Value::Int(1)); - dict.insert("two".into(), Value::Template(parse("[f]").output)); + dict.insert("two".into(), Value::Template(parse("#[f]").output)); test_pretty(BTreeMap::new(), "(:)"); - test_pretty(dict, "(one: 1, two: [[f]])"); + test_pretty(dict, "(one: 1, two: #[f])"); } } -- cgit v1.2.3