diff options
Diffstat (limited to 'src/library/container.rs')
| -rw-r--r-- | src/library/container.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/library/container.rs b/src/library/container.rs new file mode 100644 index 00000000..ae097a46 --- /dev/null +++ b/src/library/container.rs @@ -0,0 +1,26 @@ +//! 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<Node> { + let width = args.named("width")?; + let height = args.named("height")?; + let body: PackedNode = args.find().unwrap_or_default(); + Ok(Node::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<Node> { + Ok(Node::Block(args.find().unwrap_or_default())) + } +} |
