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.
|
/// Access a field on the content.
|
||||||
pub fn field(&self, name: &str) -> Option<Value> {
|
pub fn field(&self, name: &str) -> Option<Value> {
|
||||||
if let Some(iter) = self.to_sequence() {
|
if let (Some(iter), "children") = (self.to_sequence(), name) {
|
||||||
(name == "children")
|
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
|
||||||
.then(|| Value::Array(iter.cloned().map(Value::Content).collect()))
|
} else if let (Some((child, _)), "child") = (self.to_styled(), "child") {
|
||||||
} else if let Some((child, _)) = self.to_styled() {
|
Some(Value::Content(child.clone()))
|
||||||
(name == "child").then(|| Value::Content(child.clone()))
|
|
||||||
} else {
|
} else {
|
||||||
self.field_ref(name).cloned()
|
self.field_ref(name).cloned()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user