mirror of
https://github.com/typst/typst
synced 2025-05-20 03:55:29 +08:00
27 lines
702 B
Rust
27 lines
702 B
Rust
//! Inline- and block-level containers.
|
|
|
|
use super::prelude::*;
|
|
|
|
/// Size content and place it into a paragraph.
|
|
pub struct BoxNode;
|
|
|
|
#[class]
|
|
impl BoxNode {
|
|
fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> {
|
|
let width = args.named("width")?;
|
|
let height = args.named("height")?;
|
|
let body: PackedNode = args.find().unwrap_or_default();
|
|
Ok(Template::inline(body.sized(Spec::new(width, height))))
|
|
}
|
|
}
|
|
|
|
/// Place content into a separate flow.
|
|
pub struct BlockNode;
|
|
|
|
#[class]
|
|
impl BlockNode {
|
|
fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> {
|
|
Ok(Template::Block(args.find().unwrap_or_default()))
|
|
}
|
|
}
|