mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
fix: allow access to label of sequence (#342)
This commit is contained in:
parent
4d9c6b28d0
commit
84bfb3ca24
@ -165,11 +165,10 @@ impl Content {
|
||||
|
||||
/// Access a field on the content.
|
||||
pub fn field(&self, name: &str) -> Option<Value> {
|
||||
if let Some(iter) = self.to_sequence() {
|
||||
(name == "children")
|
||||
.then(|| Value::Array(iter.cloned().map(Value::Content).collect()))
|
||||
} else if let Some((child, _)) = self.to_styled() {
|
||||
(name == "child").then(|| Value::Content(child.clone()))
|
||||
if let (Some(iter), "children") = (self.to_sequence(), name) {
|
||||
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
|
||||
} else if let (Some((child, _)), "child") = (self.to_styled(), "child") {
|
||||
Some(Value::Content(child.clone()))
|
||||
} else {
|
||||
self.field_ref(name).cloned()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user