summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalo <57839069+MDLC01@users.noreply.github.com>2023-12-11 17:03:26 +0100
committerGitHub <noreply@github.com>2023-12-11 17:03:26 +0100
commitce9d4204723a41abb62c3d0600a5c02900006866 (patch)
treefaa1441dd8b4d548dfd719467726f4495e385414
parentd52fcd5b46ce3790c1cd0b1f5d84d44245f31095 (diff)
Mention `str(<label>)` feature in documentation for `label` (#2906)
-rw-r--r--crates/typst/src/foundations/label.rs3
-rw-r--r--tests/typ/compiler/label.typ7
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/typst/src/foundations/label.rs b/crates/typst/src/foundations/label.rs
index b54db6fe..91ab572d 100644
--- a/crates/typst/src/foundations/label.rs
+++ b/crates/typst/src/foundations/label.rs
@@ -12,6 +12,9 @@ use crate::util::PicoStr;
/// A labelled element can be [referenced]($ref), [queried]($query) for, and
/// [styled]($styling) through its label.
///
+/// Once constructed, you can get the name of a label using
+/// [`str`]($str/#constructor).
+///
/// # Example
/// ```example
/// #show <a>: set text(blue)
diff --git a/tests/typ/compiler/label.typ b/tests/typ/compiler/label.typ
index 407a849d..fabbac80 100644
--- a/tests/typ/compiler/label.typ
+++ b/tests/typ/compiler/label.typ
@@ -63,3 +63,10 @@ _Visible_
#test([Hello<hi>].label, <hi>)
#test([#[A *B* C]<hi>].label, <hi>)
#test([#text(red)[Hello]<hi>].label, <hi>)
+
+---
+// Test getting the name of a label.
+// Ref: false
+#test(str(<hey>), "hey")
+#test(str(label("hey")), "hey")
+#test(str([Hmm<hey>].label), "hey")