mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Pass text node to text show rule instead of string
This commit is contained in:
parent
92f2c56203
commit
9b8c1dc19f
@ -167,6 +167,13 @@ impl TextNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn field(&self, name: &str) -> Option<Value> {
|
||||||
|
match name {
|
||||||
|
"text" => Some(Value::Str(self.0.clone().into())),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for TextNode {
|
impl Debug for TextNode {
|
||||||
|
@ -419,9 +419,10 @@ impl Recipe {
|
|||||||
result.push(make(text[cursor..start].into()));
|
result.push(make(text[cursor..start].into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let transformed = self
|
let transformed = self.transform.apply(world, self.span, || {
|
||||||
.transform
|
Value::Content(make(mat.as_str().into()))
|
||||||
.apply(world, self.span, || Value::Str(mat.as_str().into()))?;
|
})?;
|
||||||
|
|
||||||
result.push(transformed);
|
result.push(transformed);
|
||||||
cursor = mat.end();
|
cursor = mat.end();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 46 KiB |
@ -47,6 +47,11 @@ Treeworld, the World of worlds, is a world.
|
|||||||
#show regex("(?i)rust"): it => [#it (🚀)]
|
#show regex("(?i)rust"): it => [#it (🚀)]
|
||||||
Rust is memory-safe and blazingly fast. Let's rewrite everything in rust.
|
Rust is memory-safe and blazingly fast. Let's rewrite everything in rust.
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test accessing the string itself.
|
||||||
|
#show "hello": it => it.text.split("").map(upper).join("|")
|
||||||
|
Oh, hello there!
|
||||||
|
|
||||||
---
|
---
|
||||||
// Replace worlds but only in lists.
|
// Replace worlds but only in lists.
|
||||||
#show list: it => [
|
#show list: it => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user