diff options
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/align.rs | 4 | ||||
| -rw-r--r-- | src/library/columns.rs | 10 | ||||
| -rw-r--r-- | src/library/container.rs | 8 | ||||
| -rw-r--r-- | src/library/deco.rs | 4 | ||||
| -rw-r--r-- | src/library/flow.rs | 4 | ||||
| -rw-r--r-- | src/library/grid.rs | 6 | ||||
| -rw-r--r-- | src/library/heading.rs | 4 | ||||
| -rw-r--r-- | src/library/hide.rs | 6 | ||||
| -rw-r--r-- | src/library/image.rs | 6 | ||||
| -rw-r--r-- | src/library/link.rs | 4 | ||||
| -rw-r--r-- | src/library/list.rs | 6 | ||||
| -rw-r--r-- | src/library/mod.rs | 6 | ||||
| -rw-r--r-- | src/library/pad.rs | 6 | ||||
| -rw-r--r-- | src/library/page.rs | 8 | ||||
| -rw-r--r-- | src/library/par.rs | 20 | ||||
| -rw-r--r-- | src/library/place.rs | 6 | ||||
| -rw-r--r-- | src/library/shape.rs | 6 | ||||
| -rw-r--r-- | src/library/spacing.rs | 8 | ||||
| -rw-r--r-- | src/library/stack.rs | 14 | ||||
| -rw-r--r-- | src/library/table.rs | 4 | ||||
| -rw-r--r-- | src/library/text.rs | 10 | ||||
| -rw-r--r-- | src/library/transform.rs | 6 |
22 files changed, 78 insertions, 78 deletions
diff --git a/src/library/align.rs b/src/library/align.rs index ecf50cc4..5d89dcb6 100644 --- a/src/library/align.rs +++ b/src/library/align.rs @@ -14,10 +14,10 @@ pub struct AlignNode { #[class] impl AlignNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let aligns: Spec<_> = args.find().unwrap_or_default(); let body: PackedNode = args.expect("body")?; - Ok(Node::block(body.aligned(aligns))) + Ok(Template::block(body.aligned(aligns))) } } diff --git a/src/library/columns.rs b/src/library/columns.rs index 5ea76973..9e696b49 100644 --- a/src/library/columns.rs +++ b/src/library/columns.rs @@ -3,7 +3,7 @@ use super::prelude::*; use super::ParNode; -/// A node that separates a region into multiple equally sized columns. +/// Separate a region into multiple equally sized columns. #[derive(Debug, Hash)] pub struct ColumnsNode { /// How many columns there should be. @@ -18,8 +18,8 @@ impl ColumnsNode { /// The size of the gutter space between each column. pub const GUTTER: Linear = Relative::new(0.04).into(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::block(Self { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::block(Self { columns: args.expect("column count")?, child: args.expect("body")?, })) @@ -116,7 +116,7 @@ pub struct ColbreakNode; #[class] impl ColbreakNode { - fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Node> { - Ok(Node::Colbreak) + fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Template> { + Ok(Template::Colbreak) } } diff --git a/src/library/container.rs b/src/library/container.rs index ae097a46..d2a4f481 100644 --- a/src/library/container.rs +++ b/src/library/container.rs @@ -7,11 +7,11 @@ pub struct BoxNode; #[class] impl BoxNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + 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(Node::inline(body.sized(Spec::new(width, height)))) + Ok(Template::inline(body.sized(Spec::new(width, height)))) } } @@ -20,7 +20,7 @@ pub struct BlockNode; #[class] impl BlockNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::Block(args.find().unwrap_or_default())) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::Block(args.find().unwrap_or_default())) } } diff --git a/src/library/deco.rs b/src/library/deco.rs index 6b38fa7a..ec2235bc 100644 --- a/src/library/deco.rs +++ b/src/library/deco.rs @@ -8,7 +8,7 @@ pub struct DecoNode<L: LineKind>(pub L); #[class] impl<L: LineKind> DecoNode<L> { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let deco = Decoration { line: L::LINE, stroke: args.named("stroke")?.or_else(|| args.find()), @@ -17,7 +17,7 @@ impl<L: LineKind> DecoNode<L> { extent: args.named("extent")?.unwrap_or_default(), evade: args.named("evade")?.unwrap_or(true), }; - Ok(args.expect::<Node>("body")?.styled(TextNode::LINES, vec![deco])) + Ok(args.expect::<Template>("body")?.styled(TextNode::LINES, vec![deco])) } } diff --git a/src/library/flow.rs b/src/library/flow.rs index 95426731..38f1b0e7 100644 --- a/src/library/flow.rs +++ b/src/library/flow.rs @@ -48,7 +48,7 @@ impl Debug for FlowChild { match self { Self::Break => f.pad("Break"), Self::Skip => f.pad("Skip"), - Self::Spacing(node) => node.fmt(f), + Self::Spacing(kind) => kind.fmt(f), Self::Node(node) => node.fmt(f), } } @@ -56,7 +56,7 @@ impl Debug for FlowChild { /// Performs flow layout. struct FlowLayouter<'a> { - /// The flow node to layout. + /// The children of the flow. children: &'a [Styled<FlowChild>], /// The regions to layout children into. regions: Regions, diff --git a/src/library/grid.rs b/src/library/grid.rs index 6a9b790a..d681ae7d 100644 --- a/src/library/grid.rs +++ b/src/library/grid.rs @@ -2,7 +2,7 @@ use super::prelude::*; -/// A node that arranges its children in a grid. +/// Arrange nodes in a grid. #[derive(Debug, Hash)] pub struct GridNode { /// Defines sizing for content rows and columns. @@ -15,13 +15,13 @@ pub struct GridNode { #[class] impl GridNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let columns = args.named("columns")?.unwrap_or_default(); let rows = args.named("rows")?.unwrap_or_default(); let base_gutter: Vec<TrackSizing> = args.named("gutter")?.unwrap_or_default(); let column_gutter = args.named("column-gutter")?; let row_gutter = args.named("row-gutter")?; - Ok(Node::block(Self { + Ok(Template::block(Self { tracks: Spec::new(columns, rows), gutter: Spec::new( column_gutter.unwrap_or_else(|| base_gutter.clone()), diff --git a/src/library/heading.rs b/src/library/heading.rs index 17efb5e4..ab0864e7 100644 --- a/src/library/heading.rs +++ b/src/library/heading.rs @@ -28,8 +28,8 @@ impl HeadingNode { /// The extra padding below the heading. pub const BELOW: Length = Length::zero(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::block(Self { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::block(Self { child: args.expect("body")?, level: args.named("level")?.unwrap_or(1), })) diff --git a/src/library/hide.rs b/src/library/hide.rs index 5025fefb..cfef8f73 100644 --- a/src/library/hide.rs +++ b/src/library/hide.rs @@ -2,14 +2,14 @@ use super::prelude::*; -/// A node that hides its child without affecting layout. +/// Hide a node without affecting layout. #[derive(Debug, Hash)] pub struct HideNode(pub PackedNode); #[class] impl HideNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::inline(Self(args.expect("body")?))) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::inline(Self(args.expect("body")?))) } } diff --git a/src/library/image.rs b/src/library/image.rs index 06b3fe31..309ffad3 100644 --- a/src/library/image.rs +++ b/src/library/image.rs @@ -5,7 +5,7 @@ use super::TextNode; use crate::diag::Error; use crate::image::ImageId; -/// An image node. +/// Show a raster or vector graphic. #[derive(Debug, Hash)] pub struct ImageNode(pub ImageId); @@ -14,7 +14,7 @@ impl ImageNode { /// How the image should adjust itself to a given area. pub const FIT: ImageFit = ImageFit::Cover; - fn construct(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(ctx: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let path = args.expect::<Spanned<EcoString>>("path to image file")?; let full = ctx.make_path(&path.v); let id = ctx.images.load(&full).map_err(|err| { @@ -27,7 +27,7 @@ impl ImageNode { let width = args.named("width")?; let height = args.named("height")?; - Ok(Node::inline( + Ok(Template::inline( ImageNode(id).pack().sized(Spec::new(width, height)), )) } diff --git a/src/library/link.rs b/src/library/link.rs index 0ecd317b..a27908c7 100644 --- a/src/library/link.rs +++ b/src/library/link.rs @@ -9,7 +9,7 @@ pub struct LinkNode; #[class] impl LinkNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let url = args.expect::<EcoString>("url")?; let body = args.find().unwrap_or_else(|| { let mut text = url.as_str(); @@ -17,7 +17,7 @@ impl LinkNode { text = text.trim_start_matches(prefix); } let shorter = text.len() < url.len(); - Node::Text(if shorter { text.into() } else { url.clone() }) + Template::Text(if shorter { text.into() } else { url.clone() }) }); Ok(body.styled(TextNode::LINK, Some(url))) diff --git a/src/library/list.rs b/src/library/list.rs index 94f7aa44..93b942b3 100644 --- a/src/library/list.rs +++ b/src/library/list.rs @@ -19,10 +19,10 @@ impl<L: ListKind> ListNode<L> { /// The space between the label and the body of each item. pub const BODY_INDENT: Linear = Relative::new(0.5).into(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { Ok(args .all() - .map(|child: PackedNode| Node::block(Self { kind: L::default(), child })) + .map(|child: PackedNode| Template::block(Self { kind: L::default(), child })) .sum()) } @@ -54,7 +54,7 @@ impl<L: ListKind> Layout for ListNode<L> { gutter: Spec::default(), children: vec![ PackedNode::default(), - Node::Text(self.kind.label()).into_block(), + Template::Text(self.kind.label()).into_block(), PackedNode::default(), self.child.clone(), ], diff --git a/src/library/mod.rs b/src/library/mod.rs index 02babebb..9b7dc0eb 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -68,7 +68,7 @@ prelude! { pub use crate::diag::{At, TypResult}; pub use crate::eval::{ - Args, Construct, EvalContext, Node, Property, Scope, Set, Smart, StyleChain, + Args, Construct, EvalContext, Template, Property, Scope, Set, Smart, StyleChain, StyleMap, Styled, Value, }; pub use crate::frame::*; @@ -227,6 +227,6 @@ castable! { castable! { PackedNode, - Expected: "node", - Value::Node(node) => node.into_block(), + Expected: "template", + Value::Template(template) => template.into_block(), } diff --git a/src/library/pad.rs b/src/library/pad.rs index 8bfc6d17..af570659 100644 --- a/src/library/pad.rs +++ b/src/library/pad.rs @@ -2,7 +2,7 @@ use super::prelude::*; -/// Pad content at the sides. +/// Pad a node at the sides. #[derive(Debug, Hash)] pub struct PadNode { /// The amount of padding. @@ -13,7 +13,7 @@ pub struct PadNode { #[class] impl PadNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let all = args.find(); let left = args.named("left")?; let top = args.named("top")?; @@ -27,7 +27,7 @@ impl PadNode { bottom.or(all).unwrap_or_default(), ); - Ok(Node::block(body.padded(padding))) + Ok(Template::block(body.padded(padding))) } } diff --git a/src/library/page.rs b/src/library/page.rs index 9949e1e7..cdb78cc1 100644 --- a/src/library/page.rs +++ b/src/library/page.rs @@ -33,8 +33,8 @@ impl PageNode { /// How many columns the page has. pub const COLUMNS: NonZeroUsize = NonZeroUsize::new(1).unwrap(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::Page(Self(args.expect("body")?))) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::Page(Self(args.expect("body")?))) } fn set(args: &mut Args, styles: &mut StyleMap) -> TypResult<()> { @@ -130,8 +130,8 @@ pub struct PagebreakNode; #[class] impl PagebreakNode { - fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Node> { - Ok(Node::Pagebreak) + fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Template> { + Ok(Template::Pagebreak) } } diff --git a/src/library/par.rs b/src/library/par.rs index 913d2253..e87d5f67 100644 --- a/src/library/par.rs +++ b/src/library/par.rs @@ -11,7 +11,7 @@ use super::prelude::*; use super::{shape, ShapedText, SpacingKind, TextNode}; use crate::util::{ArcExt, EcoString, RangeExt, SliceExt}; -/// A node that arranges its children into a paragraph. +/// Arrange text, spacing and inline nodes into a paragraph. #[derive(Hash)] pub struct ParNode(pub Vec<Styled<ParChild>>); @@ -26,12 +26,12 @@ impl ParNode { /// The spacing between paragraphs (dependent on scaled font size). pub const SPACING: Linear = Relative::new(1.2).into(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { // The paragraph constructor is special: It doesn't create a paragraph // since that happens automatically through markup. Instead, it just // lifts the passed body to the block level so that it won't merge with // adjacent stuff and it styles the contained paragraphs. - Ok(Node::Block(args.expect("body")?)) + Ok(Template::Block(args.expect("body")?)) } fn set(args: &mut Args, styles: &mut StyleMap) -> TypResult<()> { @@ -118,7 +118,7 @@ impl ParNode { fn strings(&self) -> impl Iterator<Item = &str> { self.0.iter().map(|styled| match &styled.item { ParChild::Spacing(_) => " ", - ParChild::Text(node) => &node.0, + ParChild::Text(text) => &text.0, ParChild::Node(_) => "\u{FFFC}", }) } @@ -152,8 +152,8 @@ impl ParChild { impl Debug for ParChild { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { - Self::Spacing(node) => node.fmt(f), - Self::Text(node) => node.fmt(f), + Self::Spacing(kind) => kind.fmt(f), + Self::Text(text) => text.fmt(f), Self::Node(node) => node.fmt(f), } } @@ -164,8 +164,8 @@ pub struct ParbreakNode; #[class] impl ParbreakNode { - fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Node> { - Ok(Node::Parbreak) + fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Template> { + Ok(Template::Parbreak) } } @@ -174,8 +174,8 @@ pub struct LinebreakNode; #[class] impl LinebreakNode { - fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Node> { - Ok(Node::Linebreak) + fn construct(_: &mut EvalContext, _: &mut Args) -> TypResult<Template> { + Ok(Template::Linebreak) } } diff --git a/src/library/place.rs b/src/library/place.rs index d5880995..d7b98c16 100644 --- a/src/library/place.rs +++ b/src/library/place.rs @@ -3,18 +3,18 @@ use super::prelude::*; use super::AlignNode; -/// Place content at an absolute position. +/// Place a node at an absolute position. #[derive(Debug, Hash)] pub struct PlaceNode(pub PackedNode); #[class] impl PlaceNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let aligns = args.find().unwrap_or(Spec::with_x(Some(Align::Left))); let tx = args.named("dx")?.unwrap_or_default(); let ty = args.named("dy")?.unwrap_or_default(); let body: PackedNode = args.expect("body")?; - Ok(Node::block(Self( + Ok(Template::block(Self( body.moved(Point::new(tx, ty)).aligned(aligns), ))) } diff --git a/src/library/shape.rs b/src/library/shape.rs index 0dd75c08..8ac9956f 100644 --- a/src/library/shape.rs +++ b/src/library/shape.rs @@ -5,7 +5,7 @@ use std::f64::consts::SQRT_2; use super::prelude::*; use super::TextNode; -/// Places its child into a sizable and fillable shape. +/// Place a node into a sizable and fillable shape. #[derive(Debug, Hash)] pub struct ShapeNode<S: ShapeKind> { /// Which shape to place the child into. @@ -25,7 +25,7 @@ impl<S: ShapeKind> ShapeNode<S> { /// How much to pad the shape's content. pub const PADDING: Linear = Linear::zero(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let size = if !S::ROUND && S::QUADRATIC { args.named::<Length>("size")?.map(Linear::from) } else if S::ROUND && S::QUADRATIC { @@ -44,7 +44,7 @@ impl<S: ShapeKind> ShapeNode<S> { size => size, }; - Ok(Node::inline( + Ok(Template::inline( ShapeNode { kind: S::default(), child: args.find() } .pack() .sized(Spec::new(width, height)), diff --git a/src/library/spacing.rs b/src/library/spacing.rs index 7c0c377c..6c370d38 100644 --- a/src/library/spacing.rs +++ b/src/library/spacing.rs @@ -7,8 +7,8 @@ pub struct HNode; #[class] impl HNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::Spacing(SpecAxis::Horizontal, args.expect("spacing")?)) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::Spacing(SpecAxis::Horizontal, args.expect("spacing")?)) } } @@ -17,8 +17,8 @@ pub struct VNode; #[class] impl VNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::Spacing(SpecAxis::Vertical, args.expect("spacing")?)) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::Spacing(SpecAxis::Vertical, args.expect("spacing")?)) } } diff --git a/src/library/stack.rs b/src/library/stack.rs index 14b268c2..409e5867 100644 --- a/src/library/stack.rs +++ b/src/library/stack.rs @@ -3,7 +3,7 @@ use super::prelude::*; use super::{AlignNode, SpacingKind}; -/// Stack children along an axis. +/// Arrange nodes and spacing along an axis. #[derive(Debug, Hash)] pub struct StackNode { /// The stacking direction. @@ -16,8 +16,8 @@ pub struct StackNode { #[class] impl StackNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::block(Self { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::block(Self { dir: args.named("dir")?.unwrap_or(Dir::TTB), spacing: args.named("spacing")?, children: args.all().collect(), @@ -48,7 +48,7 @@ pub enum StackChild { impl Debug for StackChild { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { - Self::Spacing(node) => node.fmt(f), + Self::Spacing(kind) => kind.fmt(f), Self::Node(node) => node.fmt(f), } } @@ -61,12 +61,12 @@ castable! { Value::Relative(v) => Self::Spacing(SpacingKind::Linear(v.into())), Value::Linear(v) => Self::Spacing(SpacingKind::Linear(v)), Value::Fractional(v) => Self::Spacing(SpacingKind::Fractional(v)), - Value::Node(v) => Self::Node(v.into_block()), + Value::Template(v) => Self::Node(v.into_block()), } /// Performs stack layout. struct StackLayouter<'a> { - /// The flow node to layout. + /// The children of the stack. children: &'a [StackChild], /// The stacking direction. dir: Dir, @@ -99,7 +99,7 @@ enum StackItem { Absolute(Length), /// Fractional spacing between other items. Fractional(Fractional), - /// A layouted child node. + /// A frame for a layouted child node. Frame(Arc<Frame>, Align), } diff --git a/src/library/table.rs b/src/library/table.rs index b0f0fbf5..33fa68cd 100644 --- a/src/library/table.rs +++ b/src/library/table.rs @@ -27,13 +27,13 @@ impl TableNode { /// How much to pad the cells's content. pub const PADDING: Linear = Length::pt(5.0).into(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { let columns = args.named("columns")?.unwrap_or_default(); let rows = args.named("rows")?.unwrap_or_default(); let base_gutter: Vec<TrackSizing> = args.named("gutter")?.unwrap_or_default(); let column_gutter = args.named("column-gutter")?; let row_gutter = args.named("row-gutter")?; - Ok(Node::block(Self { + Ok(Template::block(Self { tracks: Spec::new(columns, rows), gutter: Spec::new( column_gutter.unwrap_or_else(|| base_gutter.clone()), diff --git a/src/library/text.rs b/src/library/text.rs index 019f8c35..05b213c8 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -95,7 +95,7 @@ impl TextNode { /// Raw OpenType features to apply. pub const FEATURES: Vec<(Tag, u32)> = vec![]; - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { // The text constructor is special: It doesn't create a text node. // Instead, it leaves the passed argument structurally unchanged, but // styles all text in it. @@ -156,8 +156,8 @@ pub struct StrongNode; #[class] impl StrongNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(args.expect::<Node>("body")?.styled(TextNode::STRONG, true)) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(args.expect::<Template>("body")?.styled(TextNode::STRONG, true)) } } @@ -166,8 +166,8 @@ pub struct EmphNode; #[class] impl EmphNode { - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(args.expect::<Node>("body")?.styled(TextNode::EMPH, true)) + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(args.expect::<Template>("body")?.styled(TextNode::EMPH, true)) } } diff --git a/src/library/transform.rs b/src/library/transform.rs index e9a41a98..9d04071d 100644 --- a/src/library/transform.rs +++ b/src/library/transform.rs @@ -3,7 +3,7 @@ use super::prelude::*; use crate::geom::Transform; -/// A node that transforms its child without affecting layout. +/// Transform a node without affecting layout. #[derive(Debug, Hash)] pub struct TransformNode<T: TransformKind> { /// Transformation to apply to the contents. @@ -17,8 +17,8 @@ impl<T: TransformKind> TransformNode<T> { /// The origin of the transformation. pub const ORIGIN: Spec<Option<Align>> = Spec::default(); - fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { - Ok(Node::inline(Self { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Template> { + Ok(Template::inline(Self { kind: T::construct(args)?, child: args.expect("body")?, })) |
