diff --git a/crates/typst/src/foundations/label.rs b/crates/typst/src/foundations/label.rs index b54db6fe7..91ab572d4 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 : set text(blue) diff --git a/tests/typ/compiler/label.typ b/tests/typ/compiler/label.typ index 407a849d4..fabbac80f 100644 --- a/tests/typ/compiler/label.typ +++ b/tests/typ/compiler/label.typ @@ -63,3 +63,10 @@ _Visible_ #test([Hello].label, ) #test([#[A *B* C]].label, ) #test([#text(red)[Hello]].label, ) + +--- +// Test getting the name of a label. +// Ref: false +#test(str(), "hey") +#test(str(label("hey")), "hey") +#test(str([Hmm].label), "hey")