summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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")