summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-08 10:54:04 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-08 11:02:27 +0100
commite5eab73374880077971f3f22acbdd3d302877128 (patch)
tree07aa926b27032d6bcd82486d664dfd4161ccbd3e /library/src
parent1b2b53ecb91a9bd7fb3493e471ae03cd142a7c03 (diff)
Streamline field names
Diffstat (limited to 'library/src')
-rw-r--r--library/src/layout/align.rs10
-rw-r--r--library/src/layout/container.rs24
-rw-r--r--library/src/layout/enum.rs4
-rw-r--r--library/src/layout/flow.rs2
-rw-r--r--library/src/layout/grid.rs4
-rw-r--r--library/src/layout/list.rs4
-rw-r--r--library/src/layout/mod.rs2
-rw-r--r--library/src/layout/par.rs2
-rw-r--r--library/src/layout/table.rs4
-rw-r--r--library/src/layout/terms.rs8
-rw-r--r--library/src/math/attach.rs8
-rw-r--r--library/src/math/matrix.rs8
-rw-r--r--library/src/math/mod.rs2
-rw-r--r--library/src/meta/document.rs2
-rw-r--r--library/src/meta/heading.rs6
-rw-r--r--library/src/meta/outline.rs8
-rw-r--r--library/src/text/raw.rs2
17 files changed, 50 insertions, 50 deletions
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index bd9c60fa..e0df0436 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -20,11 +20,6 @@ use crate::prelude::*;
styles.set(Self::ALIGNMENT, aligns);
})]
pub struct AlignNode {
- /// The content to align.
- #[positional]
- #[required]
- pub body: Content,
-
/// The alignment along both axes.
///
/// Possible values for horizontal alignments are:
@@ -62,6 +57,11 @@ pub struct AlignNode {
#[skip]
#[default(Axes::new(GenAlign::Start, GenAlign::Specific(Align::Top)))]
pub alignment: Axes<Option<GenAlign>>,
+
+ /// The content to align.
+ #[positional]
+ #[required]
+ pub body: Content,
}
impl Show for AlignNode {
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index 67504ca3..8f5d69cc 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -26,7 +26,7 @@ pub struct BoxNode {
/// The contents of the box.
#[positional]
#[default]
- pub body: Content,
+ pub body: Option<Content>,
/// The width of the box.
///
@@ -133,16 +133,16 @@ impl Layout for BoxNode {
.unwrap_or(regions.base());
// Apply inset.
- let mut child = self.body();
+ let mut body = self.body().unwrap_or_default();
let inset = styles.get(Self::INSET);
if inset.iter().any(|v| !v.is_zero()) {
- child = child.padded(inset.map(|side| side.map(Length::from)));
+ body = body.padded(inset.map(|side| side.map(Length::from)));
}
// Select the appropriate base and expansion for the child depending
// on whether it is automatically or relatively sized.
let pod = Regions::one(size, expand);
- let mut frame = child.layout(vt, styles, pod)?.into_frame();
+ let mut frame = body.layout(vt, styles, pod)?.into_frame();
// Apply baseline shift.
let shift = styles.get(Self::BASELINE).relative_to(frame.height());
@@ -191,11 +191,11 @@ impl Layout for BoxNode {
/// Blocks are also useful to force elements that would otherwise be inline to
/// become block-level, especially when writing show rules.
/// ```example
-/// #show heading: it => it.title
+/// #show heading: it => it.body
/// = Blockless
/// More text.
///
-/// #show heading: it => block(it.title)
+/// #show heading: it => block(it.body)
/// = Blocky
/// More text.
/// ```
@@ -236,7 +236,7 @@ pub struct BlockNode {
/// The contents of the block.
#[positional]
#[default]
- pub body: Content,
+ pub body: Option<Content>,
/// The block's width.
///
@@ -360,10 +360,10 @@ impl Layout for BlockNode {
regions: Regions,
) -> SourceResult<Fragment> {
// Apply inset.
- let mut child = self.body();
+ let mut body = self.body().unwrap_or_default();
let inset = styles.get(Self::INSET);
if inset.iter().any(|v| !v.is_zero()) {
- child = child.clone().padded(inset.map(|side| side.map(Length::from)));
+ body = body.clone().padded(inset.map(|side| side.map(Length::from)));
}
// Resolve the sizing to a concrete size.
@@ -380,7 +380,7 @@ impl Layout for BlockNode {
// Measure to ensure frames for all regions have the same width.
if sizing.x == Smart::Auto {
let pod = Regions::one(size, Axes::splat(false));
- let frame = child.layout(vt, styles, pod)?.into_frame();
+ let frame = body.layout(vt, styles, pod)?.into_frame();
size.x = frame.width();
expand.x = true;
}
@@ -407,10 +407,10 @@ impl Layout for BlockNode {
pod.last = None;
}
- child.layout(vt, styles, pod)?.into_frames()
+ body.layout(vt, styles, pod)?.into_frames()
} else {
let pod = Regions::one(size, expand);
- child.layout(vt, styles, pod)?.into_frames()
+ body.layout(vt, styles, pod)?.into_frames()
};
// Prepare fill and stroke.
diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs
index edc954d0..853a7a67 100644
--- a/library/src/layout/enum.rs
+++ b/library/src/layout/enum.rs
@@ -77,7 +77,7 @@ pub struct EnumNode {
/// ) [+ #phase]
/// ```
#[variadic]
- pub items: Vec<EnumItem>,
+ pub children: Vec<EnumItem>,
/// If this is `{false}`, the items are spaced apart with
/// [enum spacing]($func/enum.spacing). If it is `{true}`, they use normal
@@ -203,7 +203,7 @@ impl Layout for EnumNode {
let mut parents = styles.get(Self::PARENTS);
let full = styles.get(Self::FULL);
- for item in self.items() {
+ for item in self.children() {
number = item.number().unwrap_or(number);
let resolved = if full {
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index 02f34857..8554bd98 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -34,7 +34,7 @@ impl Layout for FlowNode {
if let Some(node) = child.to::<StyledNode>() {
map = node.map();
styles = outer.chain(&map);
- child = node.sub();
+ child = node.body();
}
if let Some(node) = child.to::<VNode>() {
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index d3758fd6..b6465e1c 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -73,7 +73,7 @@ pub struct GridNode {
///
/// The cells are populated in row-major order.
#[variadic]
- pub cells: Vec<Content>,
+ pub children: Vec<Content>,
/// Defines the column sizes.
///
@@ -114,7 +114,7 @@ impl Layout for GridNode {
regions: Regions,
) -> SourceResult<Fragment> {
// Prepare grid layout by unifying content and gutter tracks.
- let cells = self.cells();
+ let cells = self.children();
let layouter = GridLayouter::new(
vt,
Axes::new(&self.columns().0, &self.rows().0),
diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs
index 69d2e717..5ba6b9b0 100644
--- a/library/src/layout/list.rs
+++ b/library/src/layout/list.rs
@@ -49,7 +49,7 @@ pub struct ListNode {
/// ]
/// ```
#[variadic]
- pub items: Vec<ListItem>,
+ pub children: Vec<ListItem>,
/// If this is `{false}`, the items are spaced apart with [list
/// spacing]($func/list.spacing). If it is `{true}`, they use normal
@@ -141,7 +141,7 @@ impl Layout for ListNode {
let marker = styles.get(Self::MARKER).resolve(vt.world(), depth)?;
let mut cells = vec![];
- for item in self.items() {
+ for item in self.children() {
cells.push(Content::empty());
cells.push(marker.clone());
cells.push(Content::empty());
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index afdfd795..96d16ec8 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -307,7 +307,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
) -> SourceResult<()> {
let map = self.scratch.maps.alloc(styled.map());
let stored = self.scratch.styles.alloc(styles);
- let content = self.scratch.content.alloc(styled.sub());
+ let content = self.scratch.content.alloc(styled.body());
let styles = stored.chain(map);
self.interrupt_style(&map, None)?;
self.accept(content, styles)?;
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index a55b2dc3..2564940c 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -521,7 +521,7 @@ fn collect<'a>(
let outer = styles;
let mut styles = *styles;
if let Some(node) = child.to::<StyledNode>() {
- child = Box::leak(Box::new(node.sub()));
+ child = Box::leak(Box::new(node.body()));
styles = outer.chain(Box::leak(Box::new(node.map())));
}
diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs
index 33ce9088..0083a7bf 100644
--- a/library/src/layout/table.rs
+++ b/library/src/layout/table.rs
@@ -40,7 +40,7 @@ use crate::prelude::*;
pub struct TableNode {
/// The contents of the table cells.
#[variadic]
- pub cells: Vec<Content>,
+ pub children: Vec<Content>,
/// Defines the column sizes.
/// See the [grid documentation]($func/grid) for more information on track
@@ -135,7 +135,7 @@ impl Layout for TableNode {
let gutter = Axes::new(self.column_gutter().0, self.row_gutter().0);
let cols = tracks.x.len().max(1);
let cells: Vec<_> = self
- .cells()
+ .children()
.into_iter()
.enumerate()
.map(|(i, child)| {
diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs
index e8adfdda..2933ea20 100644
--- a/library/src/layout/terms.rs
+++ b/library/src/layout/terms.rs
@@ -36,7 +36,7 @@ pub struct TermsNode {
/// ) [/ #product: Born in #year.]
/// ```
#[variadic]
- pub items: Vec<TermItem>,
+ pub children: Vec<TermItem>,
/// If this is `{false}`, the items are spaced apart with [term list
/// spacing]($func/terms.spacing). If it is `{true}`, they use normal
@@ -101,12 +101,12 @@ impl Layout for TermsNode {
};
let mut cells = vec![];
- for item in self.items() {
+ for child in self.children() {
let body = Content::sequence(vec![
HNode::new((-body_indent).into()).pack(),
- (item.term() + TextNode::packed(':')).strong(),
+ (child.term() + TextNode::packed(':')).strong(),
SpaceNode::new().pack(),
- item.description(),
+ child.description(),
]);
cells.push(Content::empty());
diff --git a/library/src/math/attach.rs b/library/src/math/attach.rs
index 9181ab7c..7ba1484a 100644
--- a/library/src/math/attach.rs
+++ b/library/src/math/attach.rs
@@ -79,12 +79,12 @@ pub struct ScriptsNode {
/// The base to attach the scripts to.
#[positional]
#[required]
- pub base: Content,
+ pub body: Content,
}
impl LayoutMath for ScriptsNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- self.base().layout_math(ctx)
+ self.body().layout_math(ctx)
}
}
@@ -102,12 +102,12 @@ pub struct LimitsNode {
/// The base to attach the limits to.
#[positional]
#[required]
- pub base: Content,
+ pub body: Content,
}
impl LayoutMath for LimitsNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- self.base().layout_math(ctx)
+ self.body().layout_math(ctx)
}
}
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs
index 3e257385..c7303735 100644
--- a/library/src/math/matrix.rs
+++ b/library/src/math/matrix.rs
@@ -20,7 +20,7 @@ const VERTICAL_PADDING: Ratio = Ratio::new(0.1);
pub struct VecNode {
/// The elements of the vector.
#[variadic]
- pub elements: Vec<Content>,
+ pub children: Vec<Content>,
/// The delimiter to use.
///
@@ -36,7 +36,7 @@ pub struct VecNode {
impl LayoutMath for VecNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
let delim = ctx.styles().get(Self::DELIM);
- let frame = layout_vec_body(ctx, &self.elements(), Align::Center)?;
+ let frame = layout_vec_body(ctx, &self.children(), Align::Center)?;
layout_delimiters(ctx, frame, Some(delim.open()), Some(delim.close()))
}
}
@@ -141,7 +141,7 @@ impl LayoutMath for MatNode {
pub struct CasesNode {
/// The branches of the case distinction.
#[variadic]
- pub branches: Vec<Content>,
+ pub children: Vec<Content>,
/// The delimiter to use.
///
@@ -157,7 +157,7 @@ pub struct CasesNode {
impl LayoutMath for CasesNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
let delim = ctx.styles().get(Self::DELIM);
- let frame = layout_vec_body(ctx, &self.branches(), Align::Left)?;
+ let frame = layout_vec_body(ctx, &self.children(), Align::Left)?;
layout_delimiters(ctx, frame, Some(delim.open()), None)
}
}
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index d719cb1a..6f5e5907 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -242,7 +242,7 @@ impl LayoutMath for Content {
let prev_size = ctx.size;
ctx.map.apply(prev_map.clone());
ctx.size = ctx.styles().get(TextNode::SIZE);
- styled.sub().layout_math(ctx)?;
+ styled.body().layout_math(ctx)?;
ctx.size = prev_size;
ctx.map = prev_map;
return Ok(());
diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs
index 0d03b496..29ed38fe 100644
--- a/library/src/meta/document.rs
+++ b/library/src/meta/document.rs
@@ -44,7 +44,7 @@ impl LayoutRoot for DocumentNode {
if let Some(node) = child.to::<StyledNode>() {
map = node.map();
styles = outer.chain(&map);
- child = node.sub();
+ child = node.body();
}
if let Some(page) = child.to::<PageNode>() {
diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs
index 38890885..bd95001b 100644
--- a/library/src/meta/heading.rs
+++ b/library/src/meta/heading.rs
@@ -45,7 +45,7 @@ pub struct HeadingNode {
/// The heading's title.
#[positional]
#[required]
- pub title: Content,
+ pub body: Content,
/// The logical nesting depth of the heading, starting from one.
#[named]
@@ -120,14 +120,14 @@ impl Prepare for HeadingNode {
impl Show for HeadingNode {
fn show(&self, _: &mut Vt, this: &Content, _: StyleChain) -> SourceResult<Content> {
- let mut realized = self.title();
+ let mut realized = self.body();
let numbers = this.field("numbers").unwrap();
if *numbers != Value::None {
realized = numbers.clone().display()
+ HNode::new(Em::new(0.3).into()).with_weak(true).pack()
+ realized;
}
- Ok(BlockNode::new().with_body(realized).pack())
+ Ok(BlockNode::new().with_body(Some(realized)).pack())
}
}
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index 7bc08bf9..4b5a44f7 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -103,7 +103,7 @@ impl Show for OutlineNode {
) -> SourceResult<Content> {
let mut seq = vec![ParbreakNode::new().pack()];
if let Some(title) = styles.get(Self::TITLE) {
- let body = title.clone().unwrap_or_else(|| {
+ let title = title.clone().unwrap_or_else(|| {
TextNode::packed(match styles.get(TextNode::LANG) {
Lang::GERMAN => "Inhaltsverzeichnis",
Lang::ENGLISH | _ => "Contents",
@@ -111,7 +111,7 @@ impl Show for OutlineNode {
});
seq.push(
- HeadingNode::new(body)
+ HeadingNode::new(title)
.pack()
.styled(HeadingNode::NUMBERING, None)
.styled(HeadingNode::OUTLINED, false),
@@ -161,7 +161,7 @@ impl Show for OutlineNode {
}
// Format the numbering.
- let mut start = heading.title();
+ let mut start = heading.body();
let numbers = node.field("numbers").unwrap();
if *numbers != Value::None {
start = numbers.clone().display() + SpaceNode::new().pack() + start;
@@ -175,7 +175,7 @@ impl Show for OutlineNode {
seq.push(SpaceNode::new().pack());
seq.push(
BoxNode::new()
- .with_body(filler.clone())
+ .with_body(Some(filler.clone()))
.with_width(Fr::one().into())
.pack(),
);
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs
index 8c40c6ea..4eefb0ea 100644
--- a/library/src/text/raw.rs
+++ b/library/src/text/raw.rs
@@ -171,7 +171,7 @@ impl Show for RawNode {
};
if self.block() {
- realized = BlockNode::new().with_body(realized).pack();
+ realized = BlockNode::new().with_body(Some(realized)).pack();
}
Ok(realized)