mirror of
https://github.com/typst/typst
synced 2025-05-16 10:05:28 +08:00
parent
3d83960322
commit
8aa0ae197d
@ -177,7 +177,7 @@ impl Content {
|
|||||||
pub fn field(&self, name: &str) -> Option<Value> {
|
pub fn field(&self, name: &str) -> Option<Value> {
|
||||||
if let (Some(iter), "children") = (self.to_sequence(), name) {
|
if let (Some(iter), "children") = (self.to_sequence(), name) {
|
||||||
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
|
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
|
||||||
} else if let (Some((child, _)), "child") = (self.to_styled(), "child") {
|
} else if let (Some((child, _)), "child") = (self.to_styled(), name) {
|
||||||
Some(Value::Content(child.clone()))
|
Some(Value::Content(child.clone()))
|
||||||
} else {
|
} else {
|
||||||
self.field_ref(name).cloned()
|
self.field_ref(name).cloned()
|
||||||
|
@ -56,3 +56,10 @@ _Visible_
|
|||||||
---
|
---
|
||||||
// Test that incomplete label is text.
|
// Test that incomplete label is text.
|
||||||
1 < 2 is #if 1 < 2 [not] a label.
|
1 < 2 is #if 1 < 2 [not] a label.
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test label on text, styled, and sequence.
|
||||||
|
// Ref: false
|
||||||
|
#test([Hello<hi>].label, <hi>)
|
||||||
|
#test([#[A *B* C]<hi>].label, <hi>)
|
||||||
|
#test([#text(red)[Hello]<hi>].label, <hi>)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user