From ae4accc071aa811817dd27e906f7a20d00f23949 Mon Sep 17 00:00:00 2001 From: Pg Biel <9021226+PgBiel@users.noreply.github.com> Date: Wed, 26 Apr 2023 05:03:34 -0300 Subject: Fix alignment of list markers & enum numbers (#988) --- library/src/layout/enum.rs | 3 ++- library/src/layout/list.rs | 6 +++++- tests/ref/layout/enum.png | Bin 11247 -> 16078 bytes tests/ref/layout/list.png | Bin 19085 -> 20981 bytes tests/typ/layout/enum.typ | 8 ++++++++ tests/typ/layout/list.typ | 6 ++++++ 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs index 76942c27..8814aba3 100644 --- a/library/src/layout/enum.rs +++ b/library/src/layout/enum.rs @@ -194,7 +194,8 @@ impl Layout for EnumElem { }; cells.push(Content::empty()); - cells.push(resolved); + // avoid '#set align' interference with the enum + cells.push(resolved.aligned(Align::LEFT_TOP.into())); cells.push(Content::empty()); cells.push(item.body().styled(Self::set_parents(Parent(number)))); number = number.saturating_add(1); diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs index c8aeaa06..75228d95 100644 --- a/library/src/layout/list.rs +++ b/library/src/layout/list.rs @@ -129,7 +129,11 @@ impl Layout for ListElem { }; let depth = self.depth(styles); - let marker = self.marker(styles).resolve(vt, depth)?; + let marker = self + .marker(styles) + .resolve(vt, depth)? + // avoid '#set align' interference with the list + .aligned(Align::LEFT_TOP.into()); let mut cells = vec![]; for item in self.children() { diff --git a/tests/ref/layout/enum.png b/tests/ref/layout/enum.png index a0309391..fb2c2a63 100644 Binary files a/tests/ref/layout/enum.png and b/tests/ref/layout/enum.png differ diff --git a/tests/ref/layout/list.png b/tests/ref/layout/list.png index 864a6e1d..8a3360b9 100644 Binary files a/tests/ref/layout/list.png and b/tests/ref/layout/list.png differ diff --git a/tests/typ/layout/enum.typ b/tests/typ/layout/enum.typ index 341afed4..2606a64d 100644 --- a/tests/typ/layout/enum.typ +++ b/tests/typ/layout/enum.typ @@ -34,3 +34,11 @@ See 0.3. \ Empty \ +Nope \ a + 0. + +--- +// Alignment shouldn't affect number +#set align(horizon) + ++ ABCDEF\ GHIJKL\ MNOPQR + + INNER\ INNER\ INNER ++ BACK\ HERE diff --git a/tests/typ/layout/list.typ b/tests/typ/layout/list.typ index 71ccfe35..7b938944 100644 --- a/tests/typ/layout/list.typ +++ b/tests/typ/layout/list.typ @@ -49,3 +49,9 @@ _Shopping list_ - Not in list -Nope + +--- +// Alignment shouldn't affect marker +#set align(horizon) + +- ABCDEF\ GHIJKL\ MNOPQR -- cgit v1.2.3