From 08b1c988cf77fd64cef114372c9c789228247d3c Mon Sep 17 00:00:00 2001 From: OrangeX4 <318483724@qq.com> Date: Mon, 25 Mar 2024 15:00:00 +0800 Subject: [PATCH] feat: add handle for styled --- slide.typ | 16 ++++++++++++++-- utils/utils.typ | 10 ++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/slide.typ b/slide.typ index a43e76080..fdc601e75 100644 --- a/slide.typ +++ b/slide.typ @@ -246,7 +246,7 @@ } result.push(child) } else if utils.is-sequence(child) { - // handle the list item + // handle the sequence let (conts, nextrepetitions) = _parse-content( self: self, need-cover: repetitions <= index, base: repetitions, index: index, child ) @@ -257,6 +257,18 @@ cover-arr.push(cont) } repetitions = nextrepetitions + } else if utils.is-styled(child) { + // handle styled + let (conts, nextrepetitions) = _parse-content( + self: self, need-cover: repetitions <= index, base: repetitions, index: index, child.child + ) + let cont = conts.first() + if repetitions <= index or not need-cover { + result.push(utils.typst-builtin-styled(cont, child.styles)) + } else { + cover-arr.push(utils.typst-builtin-styled(cont, child.styles)) + } + repetitions = nextrepetitions } else if type(child) == content and child.func() in (list.item, enum.item, align) { // handle the list item let (conts, nextrepetitions) = _parse-content( @@ -270,7 +282,7 @@ } repetitions = nextrepetitions } else if type(child) == content and child.func() in (pad,) { - // handle the list item + // handle the pad let (conts, nextrepetitions) = _parse-content( self: self, need-cover: repetitions <= index, base: repetitions, index: index, child.body ) diff --git a/utils/utils.typ b/utils/utils.typ index 0589793b3..fab869701 100644 --- a/utils/utils.typ +++ b/utils/utils.typ @@ -97,9 +97,15 @@ } // Type: is sequence -#let _typst-sequence = ([A] + [ ] + [B]).func() +#let typst-builtin-sequence = ([A] + [ ] + [B]).func() #let is-sequence(it) = { - type(it) == content and it.func() == _typst-sequence + type(it) == content and it.func() == typst-builtin-sequence +} + +// Type: is styled +#let typst-builtin-styled = [#set text(fill: red)].func() +#let is-styled(it) = { + type(it) == content and it.func() == typst-builtin-styled } #let reconstruct(body-name: "body", named: false, it, body) = {