Skip to content

Commit d0bbe2b

Browse files
styles: Support multi-level style root (#914)
1 parent 555f1c8 commit d0bbe2b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/styles.typ

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,29 @@
223223

224224
if base != (:) {
225225
if root != none {
226+
if type(root) != array {
227+
root = (root,)
228+
}
226229
let a = (:)
227-
a.insert(root, base)
228-
base = a
230+
for key in root.rev() {
231+
a.insert(key, base)
232+
base = a
233+
a = (:)
234+
}
229235
}
230236
dict = util.merge-dictionary(dict, base, overwrite: false)
231237
}
238+
239+
let d = if root == none {
240+
dict
241+
} else if type(root) == array {
242+
root.fold(dict, (d, k) => d.at(k))
243+
} else {
244+
dict.at(root)
245+
}
246+
232247
return resolve(
233-
if root != none { dict.at(root) } else { dict },
248+
d,
234249
if root != none {(dict,)} else {()},
235250
merge
236251
)

0 commit comments

Comments
 (0)