From 8eeb4ad8f6df3bedebdb86f95e013a9ea71fb687 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 19 Nov 2022 23:33:33 +0100 Subject: [PATCH] Rename `margins` to `margin` --- library/src/layout/page.rs | 4 ++-- tests/src/tests.rs | 3 +-- tests/typ/benches/bench.typ | 2 +- tests/typ/coma.typ | 2 +- tests/typ/graphics/image.typ | 2 +- tests/typ/graphics/shape-aspect.typ | 4 ++-- tests/typ/layout/grid-1.typ | 2 +- tests/typ/layout/grid-4.typ | 2 +- tests/typ/layout/page-margin.typ | 12 ++++++------ tests/typ/layout/page-marginals.typ | 4 ++-- tests/typ/layout/page.typ | 2 +- tests/typ/layout/stack-1.typ | 8 ++++---- tests/typ/style/show-selector.typ | 2 +- tests/typ/text/microtype.typ | 4 ++-- 14 files changed, 26 insertions(+), 27 deletions(-) diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index 6a0a3dfd6..b0e3ff6d2 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -21,7 +21,7 @@ impl PageNode { /// The page's margins. #[property(fold)] - pub const MARGINS: Sides>>> = Sides::splat(Smart::Auto); + pub const MARGIN: Sides>>> = Sides::splat(Smart::Auto); /// How many columns the page has. pub const COLUMNS: NonZeroUsize = NonZeroUsize::new(1).unwrap(); @@ -77,7 +77,7 @@ impl PageNode { // Determine the margins. let default = Rel::from(0.1190 * min); - let padding = styles.get(Self::MARGINS).map(|side| side.unwrap_or(default)); + let padding = styles.get(Self::MARGIN).map(|side| side.unwrap_or(default)); let mut child = self.0.clone(); diff --git a/tests/src/tests.rs b/tests/src/tests.rs index aa9beaee1..237eaf22c 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -148,8 +148,7 @@ fn config() -> Config { let mut styles = typst_library::styles(); styles.set(PageNode::WIDTH, Smart::Custom(Abs::pt(120.0).into())); styles.set(PageNode::HEIGHT, Smart::Auto); - styles - .set(PageNode::MARGINS, Sides::splat(Some(Smart::Custom(Abs::pt(10.0).into())))); + styles.set(PageNode::MARGIN, Sides::splat(Some(Smart::Custom(Abs::pt(10.0).into())))); styles.set(TextNode::SIZE, TextSize(Abs::pt(10.0).into())); // Hook up helpers into the global scope. diff --git a/tests/typ/benches/bench.typ b/tests/typ/benches/bench.typ index 4925db4d8..6aff1ac2f 100644 --- a/tests/typ/benches/bench.typ +++ b/tests/typ/benches/bench.typ @@ -1,5 +1,5 @@ // Configuration with `page` and `font` functions. -#set page(width: 450pt, margins: 1cm) +#set page(width: 450pt, margin: 1cm) // There are variables and they can take normal values like strings, ... #let city = "Berlin" diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ index 0e228d148..3ce869409 100644 --- a/tests/typ/coma.typ +++ b/tests/typ/coma.typ @@ -1,4 +1,4 @@ -#set page(width: 450pt, margins: 1cm) +#set page(width: 450pt, margin: 1cm) *Technische Universität Berlin* #h(1fr) *WiSe 2019/2020* \ *Fakultät II, Institut for Mathematik* #h(1fr) Woche 3 \ diff --git a/tests/typ/graphics/image.typ b/tests/typ/graphics/image.typ index 3bb5bdd12..3c906d4ff 100644 --- a/tests/typ/graphics/image.typ +++ b/tests/typ/graphics/image.typ @@ -25,7 +25,7 @@ --- // Test all three fit modes. -#set page(height: 50pt, margins: 0pt) +#set page(height: 50pt, margin: 0pt) #grid( columns: (1fr, 1fr, 1fr), rows: 100%, diff --git a/tests/typ/graphics/shape-aspect.typ b/tests/typ/graphics/shape-aspect.typ index 70d689f7d..464d1827f 100644 --- a/tests/typ/graphics/shape-aspect.typ +++ b/tests/typ/graphics/shape-aspect.typ @@ -23,7 +23,7 @@ --- // Test square that is limited by region size. -#set page(width: 20pt, height: 10pt, margins: 0pt) +#set page(width: 20pt, height: 10pt, margin: 0pt) #stack(dir: ltr, square(fill: forest), square(fill: conifer)) --- @@ -35,7 +35,7 @@ --- // Test square that is overflowing due to its aspect ratio. -#set page(width: 40pt, height: 20pt, margins: 5pt) +#set page(width: 40pt, height: 20pt, margin: 5pt) #square(width: 100%) #square(width: 100%)[Hello] diff --git a/tests/typ/layout/grid-1.typ b/tests/typ/layout/grid-1.typ index a6596c98f..dcc9b4746 100644 --- a/tests/typ/layout/grid-1.typ +++ b/tests/typ/layout/grid-1.typ @@ -31,7 +31,7 @@ ) --- -#set page(height: 3cm, margins: 0pt) +#set page(height: 3cm, margin: 0pt) #grid( columns: (1fr,), rows: (1fr, auto, 2fr), diff --git a/tests/typ/layout/grid-4.typ b/tests/typ/layout/grid-4.typ index fec251059..c7ae7649d 100644 --- a/tests/typ/layout/grid-4.typ +++ b/tests/typ/layout/grid-4.typ @@ -23,7 +23,7 @@ --- // Test that all three kinds of rows use the correct bases. -#set page(height: 4cm, margins: 0cm) +#set page(height: 4cm, margin: 0cm) #grid( rows: (1cm, 1fr, 1fr, auto), rect(height: 50%, width: 100%, fill: conifer), diff --git a/tests/typ/layout/page-margin.typ b/tests/typ/layout/page-margin.typ index 290c40819..9be2484f7 100644 --- a/tests/typ/layout/page-margin.typ +++ b/tests/typ/layout/page-margin.typ @@ -3,7 +3,7 @@ --- // Set all margins at once. [ - #set page(height: 20pt, margins: 5pt) + #set page(height: 20pt, margin: 5pt) #place(top + left)[TL] #place(bottom + right)[BR] ] @@ -11,10 +11,10 @@ --- // Set individual margins. #set page(height: 40pt) -[#set page(margins: (left: 0pt)); #align(left)[Left]] -[#set page(margins: (right: 0pt)); #align(right)[Right]] -[#set page(margins: (top: 0pt)); #align(top)[Top]] -[#set page(margins: (bottom: 0pt)); #align(bottom)[Bottom]] +[#set page(margin: (left: 0pt)); #align(left)[Left]] +[#set page(margin: (right: 0pt)); #align(right)[Right]] +[#set page(margin: (top: 0pt)); #align(top)[Top]] +[#set page(margin: (bottom: 0pt)); #align(bottom)[Bottom]] // Ensure that specific margins override general margins. -[#set page(margins: (rest: 0pt, left: 20pt)); Overriden] +[#set page(margin: (rest: 0pt, left: 20pt)); Overriden] diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ index 9b3236925..30bd39c18 100644 --- a/tests/typ/layout/page-marginals.typ +++ b/tests/typ/layout/page-marginals.typ @@ -1,6 +1,6 @@ #set page( paper: "a8", - margins: (x: 15pt, y: 30pt), + margin: (x: 15pt, y: 30pt), header: align(horizon, { text(eastern)[*Typst*] h(1fr) @@ -20,5 +20,5 @@ do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she were! She speaks yet she says nothing: what of that? Her eye discourses; I will answer it. -#set page(header: none, height: auto, margins: (top: 15pt, bottom: 25pt)) +#set page(header: none, height: auto, margin: (top: 15pt, bottom: 25pt)) The END. diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ index 918f674b4..50b6a3945 100644 --- a/tests/typ/layout/page.typ +++ b/tests/typ/layout/page.typ @@ -24,7 +24,7 @@ // Test page fill. #set page(width: 80pt, height: 40pt, fill: eastern) #text(15pt, "Roboto", fill: white, smallcaps[Typst]) -#page(width: 40pt, fill: none, margins: (top: 10pt, rest: auto))[Hi] +#page(width: 40pt, fill: none, margin: (top: 10pt, rest: auto))[Hi] --- // Just page followed by pagebreak. diff --git a/tests/typ/layout/stack-1.typ b/tests/typ/layout/stack-1.typ index 6a884667b..864a06dfb 100644 --- a/tests/typ/layout/stack-1.typ +++ b/tests/typ/layout/stack-1.typ @@ -16,12 +16,12 @@ (align(right, shaded(i, w)),) } -#set page(width: 50pt, margins: 0pt) +#set page(width: 50pt, margin: 0pt) #stack(dir: btt, ..items) --- // Test spacing. -#set page(width: 50pt, margins: 0pt) +#set page(width: 50pt, margin: 0pt) #let x = square(size: 10pt, fill: eastern) #stack( @@ -33,7 +33,7 @@ --- // Test overflow. -#set page(width: 50pt, height: 30pt, margins: 0pt) +#set page(width: 50pt, height: 30pt, margin: 0pt) #box(stack( rect(width: 40pt, height: 20pt, fill: conifer), rect(width: 30pt, height: 13pt, fill: forest), @@ -41,7 +41,7 @@ --- // Test aligning things in RTL stack with align function & fr units. -#set page(width: 50pt, margins: 5pt) +#set page(width: 50pt, margin: 5pt) #set block(spacing: 5pt) #set text(8pt) #stack(dir: rtl, 1fr, [A], 1fr, [B], [C]) diff --git a/tests/typ/style/show-selector.typ b/tests/typ/style/show-selector.typ index dc88d395b..ed8c0d8eb 100644 --- a/tests/typ/style/show-selector.typ +++ b/tests/typ/style/show-selector.typ @@ -17,7 +17,7 @@ stroke: (left: 1.5pt + luma(180)), ) -#set page(margins: (top: 12pt)) +#set page(margin: (top: 12pt)) #set par(justify: true) This code tests `code` diff --git a/tests/typ/text/microtype.typ b/tests/typ/text/microtype.typ index 28d29445b..57f9b2f23 100644 --- a/tests/typ/text/microtype.typ +++ b/tests/typ/text/microtype.typ @@ -2,7 +2,7 @@ --- // Test hanging punctuation. -#set page(width: 130pt, margins: 15pt) +#set page(width: 130pt, margin: 15pt) #set par(justify: true, linebreaks: "simple") #set text(size: 9pt) #rect(fill: rgb(0, 0, 0, 0), width: 100%)[ @@ -17,7 +17,7 @@ --- // Test that lone punctuation doesn't overhang into the margin. -#set page(margins: 0pt) +#set page(margin: 0pt) #set par(align: end) #set text(dir: rtl) :