summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-10-05 19:30:12 +0200
committerLaurenz <laurmaedje@gmail.com>2021-10-05 19:30:12 +0200
commit58d1cc68d92b2b81ea402bd33389ecbcacf1d755 (patch)
tree30c4fe83ded4df5ac659d612cfc775488e235cb1
parent155673c15e3d64fc5537041d1f5095811cc794b3 (diff)
Let `h`, `v` and `pagebreak` return template
-rw-r--r--src/library/layout.rs37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs
index 49930c95..089b80cf 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -70,23 +70,10 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
}
/// `pagebreak`: Start a new page.
-pub fn pagebreak(ctx: &mut EvalContext, _: &mut Args) -> TypResult<Value> {
- ctx.template.pagebreak(true);
- Ok(Value::None)
-}
-
-/// `h`: Horizontal spacing.
-pub fn h(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
- let spacing = args.expect("spacing")?;
- ctx.template.spacing(GenAxis::Inline, spacing);
- Ok(Value::None)
-}
-
-/// `v`: Vertical spacing.
-pub fn v(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
- let spacing = args.expect("spacing")?;
- ctx.template.spacing(GenAxis::Block, spacing);
- Ok(Value::None)
+pub fn pagebreak(_: &mut EvalContext, _: &mut Args) -> TypResult<Value> {
+ let mut template = Template::new();
+ template.pagebreak(true);
+ Ok(Value::Template(template))
}
/// `align`: Configure the alignment along the layouting axes.
@@ -139,6 +126,22 @@ pub fn align(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
})
}
+/// `h`: Horizontal spacing.
+pub fn h(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
+ let spacing = args.expect("spacing")?;
+ let mut template = Template::new();
+ template.spacing(GenAxis::Inline, spacing);
+ Ok(Value::Template(template))
+}
+
+/// `v`: Vertical spacing.
+pub fn v(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
+ let spacing = args.expect("spacing")?;
+ let mut template = Template::new();
+ template.spacing(GenAxis::Block, spacing);
+ Ok(Value::Template(template))
+}
+
/// `box`: Place content in a rectangular box.
pub fn boxed(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
let width = args.named("width")?;