Skip to content

Commit

Permalink
feat: add handle for styled
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Mar 25, 2024
1 parent 8a81348 commit 08b1c98
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
16 changes: 14 additions & 2 deletions slide.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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(
Expand All @@ -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
)
Expand Down
10 changes: 8 additions & 2 deletions utils/utils.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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) = {
Expand Down

0 comments on commit 08b1c98

Please sign in to comment.