summaryrefslogtreecommitdiff
path: root/src/syntax/pretty.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-01-28 20:02:42 +0100
committerLaurenz <laurmaedje@gmail.com>2022-01-28 20:02:42 +0100
commit76b1d4a93f6d045901f17db46d82a97c9f407703 (patch)
treef851460a038a4c543e3900352ec1a2903b6c9849 /src/syntax/pretty.rs
parent2d97d406aced1f1ab7d3bc459e31bb0eff92b892 (diff)
Parse `show` and `wrap` expressions
Diffstat (limited to 'src/syntax/pretty.rs')
-rw-r--r--src/syntax/pretty.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/syntax/pretty.rs b/src/syntax/pretty.rs
index 4a05755f..f8285f0c 100644
--- a/src/syntax/pretty.rs
+++ b/src/syntax/pretty.rs
@@ -227,6 +227,8 @@ impl Pretty for Expr {
Self::With(v) => v.pretty(p),
Self::Let(v) => v.pretty(p),
Self::Set(v) => v.pretty(p),
+ Self::Show(v) => v.pretty(p),
+ Self::Wrap(v) => v.pretty(p),
Self::If(v) => v.pretty(p),
Self::While(v) => v.pretty(p),
Self::For(v) => v.pretty(p),
@@ -456,6 +458,24 @@ impl Pretty for SetExpr {
}
}
+impl Pretty for ShowExpr {
+ fn pretty(&self, p: &mut Printer) {
+ p.push_str("show ");
+ self.pattern().pretty(p);
+ p.push_str(" as ");
+ self.body().pretty(p);
+ }
+}
+
+impl Pretty for WrapExpr {
+ fn pretty(&self, p: &mut Printer) {
+ p.push_str("wrap ");
+ self.binding().pretty(p);
+ p.push_str(" in ");
+ self.body().pretty(p);
+ }
+}
+
impl Pretty for IfExpr {
fn pretty(&self, p: &mut Printer) {
p.push_str("if ");
@@ -652,6 +672,8 @@ mod tests {
roundtrip("#let x = 1 + 2");
roundtrip("#let f(x) = y");
roundtrip("#set text(size: 12pt)");
+ roundtrip("#show heading(body) as [*{body}*]");
+ roundtrip("#wrap body in columns(2, body)");
roundtrip("#if x [y] else [z]");
roundtrip("#if x {} else if y {} else {}");
roundtrip("#while x {y}");