Let h, v and pagebreak return template

This commit is contained in:
Laurenz 2021-10-05 19:30:12 +02:00
parent 155673c15e
commit 58d1cc68d9

View File

@ -70,23 +70,10 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
} }
/// `pagebreak`: Start a new page. /// `pagebreak`: Start a new page.
pub fn pagebreak(ctx: &mut EvalContext, _: &mut Args) -> TypResult<Value> { pub fn pagebreak(_: &mut EvalContext, _: &mut Args) -> TypResult<Value> {
ctx.template.pagebreak(true); let mut template = Template::new();
Ok(Value::None) template.pagebreak(true);
} Ok(Value::Template(template))
/// `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)
} }
/// `align`: Configure the alignment along the layouting axes. /// `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. /// `box`: Place content in a rectangular box.
pub fn boxed(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { pub fn boxed(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
let width = args.named("width")?; let width = args.named("width")?;