Skip to content

Commit

Permalink
fix: allow access to label of sequence (typst#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDertoni authored Mar 30, 2023
1 parent 4d9c6b2 commit 84bfb3c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/model/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 84bfb3c

Please sign in to comment.