From 79558f44a015896f999e3c31e4147b1e78786603 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 26 Sep 2024 08:39:39 +0000 Subject: [PATCH] Clarify syntactical difference in `label` function docs (#4957) --- crates/typst/src/foundations/label.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/typst/src/foundations/label.rs b/crates/typst/src/foundations/label.rs index 8f15d3178..314fc8a90 100644 --- a/crates/typst/src/foundations/label.rs +++ b/crates/typst/src/foundations/label.rs @@ -29,6 +29,16 @@ use crate::utils::PicoStr; /// its name in angle brackets. This works both in markup and code. A label's /// name can contain letters, numbers, `_`, `-`, `:`, and `.`. /// +/// Note that there is a syntactical difference when using the dedicated syntax +/// for this function. In the code below, the `[]` terminates the heading and +/// thus attaches to the heading itself, whereas the `[#label("b")]` is part of +/// the heading and thus attaches to the heading's text. +/// +/// ```typ +/// = Intro // Equivalent to `#heading[Intro] `. +/// = Concl #label("b") // Equivalent to `#heading[Concl #label("b")]`. +/// ``` +/// /// Currently, labels can only be attached to elements in markup mode, not in /// code mode. This might change in the future. #[ty(scope, cast)]