From a1a521523451c693218274d2f88466a07bfff9ea Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:25:47 -0300 Subject: [PATCH] Ensure par and align interrupt cite groups and lists (#5526) --- crates/typst-realize/src/lib.rs | 6 +++-- ...03-cite-group-interrupted-by-par-align.png | Bin 0 -> 1487 bytes tests/ref/issue-5503-cite-in-align.png | Bin 0 -> 393 bytes ...sue-5503-enum-interrupted-by-par-align.png | Bin 0 -> 1004 bytes ...sue-5503-list-interrupted-by-par-align.png | Bin 0 -> 415 bytes ...ue-5503-terms-interrupted-by-par-align.png | Bin 0 -> 569 bytes tests/suite/model/cite.typ | 22 ++++++++++++++++++ tests/suite/model/enum.typ | 12 ++++++++++ tests/suite/model/list.typ | 15 ++++++++++++ tests/suite/model/terms.typ | 15 ++++++++++++ 10 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 tests/ref/issue-5503-cite-group-interrupted-by-par-align.png create mode 100644 tests/ref/issue-5503-cite-in-align.png create mode 100644 tests/ref/issue-5503-enum-interrupted-by-par-align.png create mode 100644 tests/ref/issue-5503-list-interrupted-by-par-align.png create mode 100644 tests/ref/issue-5503-terms-interrupted-by-par-align.png diff --git a/crates/typst-realize/src/lib.rs b/crates/typst-realize/src/lib.rs index c46a15351..fd43e8304 100644 --- a/crates/typst-realize/src/lib.rs +++ b/crates/typst-realize/src/lib.rs @@ -836,7 +836,9 @@ static CITES: GroupingRule = GroupingRule { tags: false, trigger: |content, _| content.elem() == CiteElem::elem(), inner: |content| content.elem() == SpaceElem::elem(), - interrupt: |elem| elem == CiteGroup::elem(), + interrupt: |elem| { + elem == CiteGroup::elem() || elem == ParElem::elem() || elem == AlignElem::elem() + }, finish: finish_cites, }; @@ -859,7 +861,7 @@ const fn list_like_grouping() -> GroupingRule { let elem = content.elem(); elem == SpaceElem::elem() || elem == ParbreakElem::elem() }, - interrupt: |elem| elem == T::elem(), + interrupt: |elem| elem == T::elem() || elem == AlignElem::elem(), finish: finish_list_like::, } } diff --git a/tests/ref/issue-5503-cite-group-interrupted-by-par-align.png b/tests/ref/issue-5503-cite-group-interrupted-by-par-align.png new file mode 100644 index 0000000000000000000000000000000000000000..166331587009d036a445d95c3478dac114015d58 GIT binary patch literal 1487 zcmV;=1u*)FP)!yuQY8a(c$b#{K>MR8&^^`TG0&{PObh?CtTCmY(OVnAlq|_4Tf+9>Wv%9pkw9L%RFfux7Y;?D` zw}*#^j*gCujEwN`@P>wlv*4n|t%V=tHy1T!ttEanCa>3l$4fQ zT3oNOxp8xQz`(-u^YcJJK%k(Ym6esSu&_KmL0Vj7t*x(QW^Ui#;o#unsHm!vl$>d6 zbDo}_U0-LZsjFOGX1Tk=yS>G|zQkW)X}`hA!^O?T$Ir>j)9UK%>+9{$&(YD-+t%3N z-rwcY)Z9^1Tkh`ei;Ih&pPyb}XsW8Ld3%F}hmW$fyn1|uy}!rS*4W_S;Q9Ia)79Ob zpQoRpsfvu0wz$AfP*_b*S4&M*R8&-TcYjPyR?g7a^YivnQ&-p7;nmmQmzkk|fr+lL zxPE|$@$vEQ@AFSlS>4~~v+#k$0008gNklq~ zTwUuyK+6(9UoH?cvAP5B*3%wHv!}9#O+Z7Bp8!m@ z@Gs1ds5cjD`2oKw$1z`zgfbsGb0A&K(unG8}wY-nnhf&4DjKT$J$w|z^ zR7L6M#KcdOs+Smjc zBM4jFy=$alH!OxPQ;y^633~n7Rce;oxswwyb57rXi%PoAn(0VngmM5yg#dK6o5Vh# zu#E7tvb8ka z{2CLB;gQw{2R~Q7UOA3aM)(}HH1h582vaVh^X3b}H(}S#-HgAxO9B1KWB{dL8#V!6 zCrkiL?8Er@--Q!&%7lXl4eZA}On&@%VC&!kJ89G$KEjtN$8mM7neCswloy04cmVpM z;sSitvA;<)_43SC8D@9)SZ0m pbaN+c-A%PF5dXG(nQ~lx@*8WC00B1gL@odT002ovPDHLkV1mnpGGG7z literal 0 HcmV?d00001 diff --git a/tests/ref/issue-5503-cite-in-align.png b/tests/ref/issue-5503-cite-in-align.png new file mode 100644 index 0000000000000000000000000000000000000000..aeb72aa0d169fee63a9e8db9bef41fbd4427cc4a GIT binary patch literal 393 zcmV;40e1e0P)gwwD_V(D=*xK6KU0q!@H8n;?MvIG!m6er0K}p)&_3000000NkvXXu0mjfe@M+w literal 0 HcmV?d00001 diff --git a/tests/ref/issue-5503-enum-interrupted-by-par-align.png b/tests/ref/issue-5503-enum-interrupted-by-par-align.png new file mode 100644 index 0000000000000000000000000000000000000000..9cc942b4cc09c57c1cce0c1408e01cf2e972699f GIT binary patch literal 1004 zcmVb|=u zb^-ueRHpRzG#~^MOfbPy85Ry-X9)A!D|ykbC}9Yj>+o+d(z=p&>|kJI38L_N!=edh za4>xc;*F77#|%F0>K~tk_jIy?O^dVRLnr$H0F_(s9Rw@bWwZCf!2hi$Z61QSd! z!BY`-H3wyZ>$Q)!$pX81ZGN;>4Jv&Iru;X;xrVe)62o}7q#~N?^??Hhb8AluiZ}E@ zY8d>VT%_~`xW6l?tBQsC5~PO5G5!w*g)p3pa&=+t*aDQ5NDjB1F0vrwWf+bxJrin6 zH6)q$?sl_$kM#xe3<#gRd_)!)9?t}AHNgZE{G;&eR1Z72t7@_l_mLUQZBUAh;PN46 zaFJ1j2To{yWd^sjH;C}=E+jC6Zz+@Gdm^1+0mDZP?J-;$000y#+W%HFgZ(#aKRp@? zchjRML$q836HG9{QxA4J?DD|Nj+Dv*4{9d6_IZ^RXs_@JHP1Ah#Bg7xLLF`8syAzz zp4M6p;#87}mly{4-=l`U0QGzE@M;{?7XgW30m5GhMc{l?=T&O_3vszja@evZrw+;X zFubUAkN-|e)g1G>)zjkR3y!A*WP$m%HXm&@!2}chgK)pj$`I~u6?3Q8zz(jyAf_`J zU0r1L#mpGo z)Q1?c1P-=ryM`F_Ct`U;&Z~jk^c)NgE8Xe;0veVfsgZ!`MiN_ zYwM04kC*rQ*bYcAc63-dA;)rcYnyo5YJv%#Hn82s6n-k!nM{VTko%k14^A+>@w`bm zO|`=<$B)ksR*dEuWr4F$S;h{Y1=s=r08={33z@;Xjdzgq766cah&!GUq~#)*V1fz$ a_Iv?W=#otA7_LeH0000%wxAq))we5$W( zqlC2pa+cDYcP+VTJR*i+Dn*v6&+-Cj;SS8@k7eBpDJ=RStliO^Bmz=m_MHw6*?dl? zVh={Q{h~d8!Ue)G!wfV0U*Pjo89<9qJ9}~jR0>Gm{IU~Z>0x|qB*o?b8 z7ryBfF${f69!Vm)3R*Z0eXE+*#iI^FIMy56H54>4XJRFt8jH}u_sX5}R7q#+S4H5a z!_CDo!wfV0Ggulw1Q2Mep-Tv3008Rhdu=BlUlwa3xRu$UA76~6h&y{rKE43va$|Dl zl@=ZXT*8z;gM06Cju4g%UdNO&;SYJ&n+;2t3xr{Y8D{v~eF5@?n6e%z(Fy=G`P)qI zPjl*XWq^m#t;VPD44m`UXj0{@!Sz(QzjZrWMz=*izgN zJ0*c<@`HhcxiUaCf-I~&!C2;R@!?+#_OEX78&gW)%@EQBcmA$9sSq6w)V^DQwYoFe z%y=TImia3CU&jAIH$w$NFu?>9d;#G@qh)BYhm#(jRr@o#2kNAU_fsff5l^lF!MI=W z30`442t?Tf@qc^_M=GZu>}FRnvzObepZ&?@)+&2jC4rmYb}19;9^e+ZVtnZh-L?vn zz?z=`)HWaso??9cA6_faiViPd|CVsy>^H{pYE!G1mJN5KN|n~!W)U3@xLF=y7r)1` z$q*OvaZ#3wxqQ@I1QSd!!Doca8!L+HU&sLK(4m4(w((`rU_z&{&hg&a@NcZfi%EUE zB(RXTUeZ66v3U6UlW@iBs(>P8kpy-sY}U}}@ue%%CO+IzgY9%4dyW!-vEl}n9>wgN z*`mXNa^(Vkl(p?NJ@!P3n&xvRw1vKxx;`opf(a&=;FBBycoS&Zfmn~t00000NkvXX Hu0mjfmu3tE literal 0 HcmV?d00001 diff --git a/tests/suite/model/cite.typ b/tests/suite/model/cite.typ index 902800818..b328dda49 100644 --- a/tests/suite/model/cite.typ +++ b/tests/suite/model/cite.typ @@ -114,6 +114,28 @@ B #cite() #cite(). #show bibliography: none #bibliography("/assets/bib/works.bib", style: "chicago-author-date") +--- issue-5503-cite-in-align --- +// The two aligned elements should be displayed in separate lines. +#align(right)[@netwok] +#align(right)[b] + +#show bibliography: none +#bibliography("/assets/bib/works.bib") + +--- issue-5503-cite-group-interrupted-by-par-align --- +// `par` and `align` are block-level and should interrupt a cite group +@netwok +@arrgh +#par(leading: 5em)[@netwok] +#par[@arrgh] +@netwok +@arrgh +#align(right)[@netwok] +@arrgh + +#show bibliography: none +#bibliography("/assets/bib/works.bib") + --- cite-type-error-hint --- // Test hint for cast error from str to label // Error: 7-15 expected label, found string diff --git a/tests/suite/model/enum.typ b/tests/suite/model/enum.typ index ed33157e8..c5e562159 100644 --- a/tests/suite/model/enum.typ +++ b/tests/suite/model/enum.typ @@ -163,3 +163,15 @@ a + 0. // Enum item (pre-emptive) #enum.item(none)[Hello] #enum.item(17)[Hello] + +--- issue-5503-enum-interrupted-by-par-align --- +// `align` is block-level and should interrupt an enum +// but not a `par` ++ a ++ b +#par(leading: 5em)[+ par] ++ d +#par[+ par] ++ f +#align(right)[+ align] ++ h diff --git a/tests/suite/model/list.typ b/tests/suite/model/list.typ index aa117672c..138abf70e 100644 --- a/tests/suite/model/list.typ +++ b/tests/suite/model/list.typ @@ -218,3 +218,18 @@ World part($ x $ + parbreak() + list[A]) part($ x $ + parbreak() + parbreak() + list[A]) } + +--- issue-5503-list-interrupted-by-par-align --- +// `align` is block-level and should interrupt a list +// but not a `par` +#show list: [List] +- a +- b +#par(leading: 5em)[- c] +- d +- e +#par[- f] +- g +- h +#align(right)[- i] +- j diff --git a/tests/suite/model/terms.typ b/tests/suite/model/terms.typ index 07aa827dc..61fe20b0d 100644 --- a/tests/suite/model/terms.typ +++ b/tests/suite/model/terms.typ @@ -75,3 +75,18 @@ Not in list --- issue-2530-term-item-panic --- // Term item (pre-emptive) #terms.item[Hello][World!] + +--- issue-5503-terms-interrupted-by-par-align --- +// `align` is block-level and should interrupt a `terms` +// but not a `par` +#show terms: [Terms] +/ a: a +/ b: b +#par(leading: 5em)[/ c: c] +/ d: d +/ e: e +#par[/ f: f] +/ g: g +/ h: h +#align(right)[/ i: i] +/ j: j