summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-05-17 14:38:03 +0200
committerLaurenz <laurmaedje@gmail.com>2023-05-17 14:38:03 +0200
commit42afa410ae561eb5b267080d088bca529a5d0b54 (patch)
treebdea7348daef7409490ba542f9bdec5d52732d03 /library
parent8971588486b6ffa9269344b4bda71de86af9d908 (diff)
Better documentation outlines
Diffstat (limited to 'library')
-rw-r--r--library/src/compute/calc.rs62
-rw-r--r--library/src/compute/construct.rs22
-rw-r--r--library/src/compute/data.rs12
-rw-r--r--library/src/compute/foundations.rs18
-rw-r--r--library/src/layout/align.rs2
-rw-r--r--library/src/layout/columns.rs4
-rw-r--r--library/src/layout/container.rs4
-rw-r--r--library/src/layout/enum.rs4
-rw-r--r--library/src/layout/grid.rs2
-rw-r--r--library/src/layout/hide.rs2
-rw-r--r--library/src/layout/list.rs4
-rw-r--r--library/src/layout/measure.rs1
-rw-r--r--library/src/layout/pad.rs2
-rw-r--r--library/src/layout/page.rs4
-rw-r--r--library/src/layout/par.rs6
-rw-r--r--library/src/layout/place.rs2
-rw-r--r--library/src/layout/repeat.rs2
-rw-r--r--library/src/layout/spacing.rs6
-rw-r--r--library/src/layout/stack.rs2
-rw-r--r--library/src/layout/table.rs2
-rw-r--r--library/src/layout/terms.rs4
-rw-r--r--library/src/layout/transform.rs6
-rw-r--r--library/src/math/accent.rs2
-rw-r--r--library/src/math/attach.rs8
-rw-r--r--library/src/math/cancel.rs2
-rw-r--r--library/src/math/delimited.rs12
-rw-r--r--library/src/math/frac.rs6
-rw-r--r--library/src/math/matrix.rs6
-rw-r--r--library/src/math/mod.rs4
-rw-r--r--library/src/math/op.rs4
-rw-r--r--library/src/math/root.rs4
-rw-r--r--library/src/math/style.rs14
-rw-r--r--library/src/math/underover.rs12
-rw-r--r--library/src/meta/counter.rs14
-rw-r--r--library/src/meta/figure.rs4
-rw-r--r--library/src/meta/heading.rs4
-rw-r--r--library/src/meta/link.rs4
-rw-r--r--library/src/meta/numbering.rs2
-rw-r--r--library/src/meta/outline.rs4
-rw-r--r--library/src/meta/query.rs6
-rw-r--r--library/src/meta/reference.rs6
-rw-r--r--library/src/meta/state.rs8
-rw-r--r--library/src/text/deco.rs6
-rw-r--r--library/src/text/misc.rs20
-rw-r--r--library/src/text/mod.rs2
-rw-r--r--library/src/text/quotes.rs4
-rw-r--r--library/src/text/raw.rs4
-rw-r--r--library/src/text/shift.rs4
-rw-r--r--library/src/visualize/image.rs2
-rw-r--r--library/src/visualize/line.rs2
-rw-r--r--library/src/visualize/path.rs2
-rw-r--r--library/src/visualize/polygon.rs2
-rw-r--r--library/src/visualize/shape.rs8
53 files changed, 178 insertions, 177 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index 708d795d..6008828c 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -52,7 +52,7 @@ pub fn module() -> Module {
/// Calculate the absolute value of a numeric value.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.abs(-5) \
/// #calc.abs(5pt - 2cm) \
@@ -86,7 +86,7 @@ cast_from_value! {
/// Raise a value to some exponent.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.pow(2, 3)
/// ```
@@ -133,7 +133,7 @@ pub fn pow(
/// Calculate the square root of a number.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.sqrt(16) \
/// #calc.sqrt(2.5)
@@ -158,7 +158,7 @@ pub fn sqrt(
/// When called with an integer or a float, they will be interpreted as
/// radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.sin(90deg) == calc.sin(-270deg))
/// #calc.sin(1.5) \
@@ -185,7 +185,7 @@ pub fn sin(
/// When called with an integer or a float, they will be interpreted as
/// radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.cos(90deg) \
/// #calc.cos(1.5) \
@@ -212,7 +212,7 @@ pub fn cos(
/// When called with an integer or a float, they will be interpreted as
/// radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.tan(1.5) \
/// #calc.tan(90deg)
@@ -235,7 +235,7 @@ pub fn tan(
/// Calculate the arcsine of a number.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.asin(0) \
/// #calc.asin(1)
@@ -258,7 +258,7 @@ pub fn asin(
/// Calculate the arccosine of a number.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.acos(0) \
/// #calc.acos(1)
@@ -281,7 +281,7 @@ pub fn acos(
/// Calculate the arctangent of a number.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.atan(0) \
/// #calc.atan(1)
@@ -302,7 +302,7 @@ pub fn atan(
///
/// The arguments are `(x, y)`, not `(y, x)`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.atan2(1, 1) \
/// #calc.atan2(-2, -3)
@@ -325,7 +325,7 @@ pub fn atan2(
///
/// When called with an integer or a float, they will be interpreted as radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.sinh(0) \
/// #calc.sinh(45deg)
@@ -350,7 +350,7 @@ pub fn sinh(
///
/// When called with an integer or a float, they will be interpreted as radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.cosh(0) \
/// #calc.cosh(45deg)
@@ -375,7 +375,7 @@ pub fn cosh(
///
/// When called with an integer or a float, they will be interpreted as radians.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.tanh(0) \
/// #calc.tanh(45deg)
@@ -400,7 +400,7 @@ pub fn tanh(
///
/// If the base is not specified, the logarithm is calculated in base 10.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.log(100)
/// ```
@@ -443,7 +443,7 @@ pub fn log(
/// Calculate the factorial of a number.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.fact(5)
/// ```
@@ -481,7 +481,7 @@ fn factorial_range(start: u64, end: u64) -> Option<i64> {
/// Calculate a permutation.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.perm(10, 5)
/// ```
@@ -509,7 +509,7 @@ pub fn perm(
/// Calculate a binomial coefficient.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.binom(10, 5)
/// ```
@@ -554,7 +554,7 @@ fn binomial(n: u64, k: u64) -> Option<i64> {
/// Calculate the greatest common divisor of two integers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.gcd(7, 42)
/// ```
@@ -586,7 +586,7 @@ fn calculate_gcd(mut a: i64, mut b: i64) -> i64 {
/// Calculate the least common multiple of two integers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.lcm(96, 13)
/// ```
@@ -622,7 +622,7 @@ fn calculate_lcm(a: i64, b: i64) -> Option<i64> {
///
/// If the number is already an integer, it is returned unchanged.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.floor(3.14) == 3)
/// #assert(calc.floor(3) == 3)
@@ -647,7 +647,7 @@ pub fn floor(
///
/// If the number is already an integer, it is returned unchanged.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.ceil(3.14) == 4)
/// #assert(calc.ceil(3) == 3)
@@ -672,7 +672,7 @@ pub fn ceil(
///
/// If the number is already an integer, it is returned unchanged.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.trunc(3) == 3)
/// #assert(calc.trunc(-3.7) == -3)
@@ -697,7 +697,7 @@ pub fn trunc(
///
/// If the number is an integer, it returns `0`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.fract(3) == 0)
/// #calc.fract(-3.1)
@@ -721,7 +721,7 @@ pub fn fract(
///
/// Optionally, a number of decimal places can be specified.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.round(3.14) == 3)
/// #assert(calc.round(3.5) == 4)
@@ -752,7 +752,7 @@ pub fn round(
/// Clamp a number between a minimum and maximum value.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #assert(calc.clamp(5, 0, 10) == 5)
/// #assert(calc.clamp(5, 6, 10) == 6)
@@ -779,7 +779,7 @@ pub fn clamp(
/// Determine the minimum of a sequence of values.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.min(1, -3, -5, 20, 3, 6) \
/// #calc.min("typst", "in", "beta")
@@ -800,7 +800,7 @@ pub fn min(
/// Determine the maximum of a sequence of values.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.max(1, -3, -5, 20, 3, 6) \
/// #calc.max("typst", "in", "beta")
@@ -851,7 +851,7 @@ fn minmax(
/// Determine whether an integer is even.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.even(4) \
/// #calc.even(5) \
@@ -871,7 +871,7 @@ pub fn even(
/// Determine whether an integer is odd.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.odd(4) \
/// #calc.odd(5) \
@@ -891,7 +891,7 @@ pub fn odd(
/// Calculate the remainder of two numbers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.rem(20, 6) \
/// #calc.rem(1.75, 0.5)
@@ -936,7 +936,7 @@ pub fn mod_(
/// Calculate the quotient of two numbers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #calc.quo(14, 5) \
/// #calc.quo(3.46, 0.5)
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index 4ba73a73..1c5775e5 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -11,7 +11,7 @@ use crate::prelude::*;
/// - Floats are floored to the next 64-bit integer.
/// - Strings are parsed in base 10.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #int(false) \
/// #int(true) \
@@ -49,7 +49,7 @@ cast_from_value! {
/// - Strings are parsed in base 10 to the closest 64-bit float.
/// Exponential notation is supported.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #float(false) \
/// #float(true) \
@@ -84,7 +84,7 @@ cast_from_value! {
/// Create a grayscale color.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #for x in range(250, step: 50) {
/// box(square(fill: luma(x)))
@@ -110,7 +110,7 @@ pub fn luma(
/// render them correctly, the PDF export does not handle them properly at the
/// moment. This will be fixed in the future.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #square(fill: rgb("#b1f2eb"))
/// #square(fill: rgb(87, 127, 230))
@@ -190,7 +190,7 @@ cast_from_value! {
/// to RGB for display preview might differ from how your printer reproduces
/// the color.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #square(
/// fill: cmyk(27%, 0%, 3%, 5%)
@@ -228,7 +228,7 @@ cast_from_value! {
/// Create a custom symbol with modifiers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let envelope = symbol(
/// "🖂",
@@ -294,7 +294,7 @@ cast_from_value! {
/// - Floats are formatted in base 10 and never in exponential notation.
/// - From labels the name is extracted.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #str(10) \
/// #str(2.7) \
@@ -330,7 +330,7 @@ cast_from_value! {
/// that is not a space. Then, the element can be [referenced]($func/ref) and
/// styled through the label.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #show <a>: set text(blue)
/// #show label("b"): set text(red)
@@ -339,7 +339,7 @@ cast_from_value! {
/// *Strong* #label("b")
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: You can create a label by enclosing
/// its name in angle brackets. This works both in markup and code.
///
@@ -363,7 +363,7 @@ pub fn label(
/// [See here](https://docs.rs/regex/latest/regex/#syntax) for a specification
/// of the supported syntax.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // Works with show rules.
/// #show regex("\d+"): set text(red)
@@ -401,7 +401,7 @@ pub fn regex(
/// the range. If you pass two, they describe the `start` and `end` of the
/// range.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #range(5) \
/// #range(2, 5) \
diff --git a/library/src/compute/data.rs b/library/src/compute/data.rs
index d104cf27..d97a3782 100644
--- a/library/src/compute/data.rs
+++ b/library/src/compute/data.rs
@@ -6,7 +6,7 @@ use crate::prelude::*;
///
/// The file will be read and returned as a string.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let text = read("data.html")
///
@@ -38,7 +38,7 @@ pub fn read(
/// rows will be collected into a single array. Header rows will not be
/// stripped.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let results = csv("data.csv")
///
@@ -138,7 +138,7 @@ fn format_csv_error(error: csv::Error, line: usize) -> EcoString {
/// The JSON files in the example contain objects with the keys `temperature`,
/// `unit`, and `weather`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let forecast(day) = block[
/// #box(square(
@@ -218,7 +218,7 @@ fn format_json_error(error: serde_json::Error) -> EcoString {
/// The TOML file in the example consists of a table with the keys `title`,
/// `version`, and `authors`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let details = toml("details.toml")
///
@@ -302,7 +302,7 @@ fn format_toml_error(error: toml::de::Error) -> EcoString {
/// each with a sequence of their own submapping with the keys
/// "title" and "published"
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let bookshelf(contents) = {
/// for (author, works) in contents {
@@ -384,7 +384,7 @@ fn format_yaml_error(error: serde_yaml::Error) -> EcoString {
/// `content` tag contains one or more paragraphs, which are represented as `p`
/// tags.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #let findChild(elem, tag) = {
/// elem.children
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs
index 5127fca3..6a92c2a8 100644
--- a/library/src/compute/foundations.rs
+++ b/library/src/compute/foundations.rs
@@ -4,7 +4,7 @@ use crate::prelude::*;
///
/// Returns the name of the value's type.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #type(12) \
/// #type(14.7) \
@@ -34,7 +34,7 @@ pub fn type_(
/// **Note:** This function is for debugging purposes. Its output should not be
/// considered stable and may change at any time!
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #none vs #repr(none) \
/// #"hello" vs #repr("hello") \
@@ -55,7 +55,7 @@ pub fn repr(
/// Fail with an error.
///
-/// ## Example
+/// ## Example { #example }
/// The code below produces the error `panicked with: "this is wrong"`.
/// ```typ
/// #panic("this is wrong")
@@ -91,7 +91,7 @@ pub fn panic(
/// If you wish to test equality between two values, see
/// [`assert.eq`]($func/assert.eq) and [`assert.ne`]($func/assert.ne).
///
-/// ## Example
+/// ## Example { #example }
/// ```typ
/// #assert(1 < 2, message: "math broke")
/// ```
@@ -128,8 +128,8 @@ pub fn assert(
/// Fails with an error if the first value is not equal to the second. Does not
/// produce any output in the document.
///
-/// ## Example
-/// ```example
+/// ## Example { #example }
+/// ```typ
/// #assert.eq(10, 10)
/// ```
///
@@ -170,8 +170,8 @@ pub fn assert_eq(
/// Fails with an error if the first value is equal to the second. Does not
/// produce any output in the document.
///
-/// ## Example
-/// ```example
+/// ## Example { #example }
+/// ```typ
/// #assert.ne(3, 4)
/// ```
///
@@ -211,7 +211,7 @@ pub fn assert_ne(
///
/// This function should only be used as a last resort.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #eval("1 + 1") \
/// #eval("(1, 2, 3, 4)").len() \
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index b8f7a086..4c9beb63 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -2,7 +2,7 @@ use crate::prelude::*;
/// Align content horizontally and vertically.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set align(center)
///
diff --git a/library/src/layout/columns.rs b/library/src/layout/columns.rs
index 2a587907..06e6a7e0 100644
--- a/library/src/layout/columns.rs
+++ b/library/src/layout/columns.rs
@@ -9,7 +9,7 @@ use crate::text::TextElem;
/// height on the page. The columns function can break across pages if
/// necessary.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// = Towards Advanced Deep Learning
///
@@ -132,7 +132,7 @@ impl Layout for ColumnsElem {
/// single column layout or the last column on a page. Otherwise, content after
/// the column break will be placed in the next column.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set page(columns: 2)
/// Preliminary findings from our
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index ae6a094c..04c58075 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -9,7 +9,7 @@ use crate::prelude::*;
/// elements into a paragraph. Boxes take the size of their contents by default
/// but can also be sized explicitly.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Refer to the docs
/// #box(
@@ -170,7 +170,7 @@ impl Layout for BoxElem {
/// Such a container can be used to separate content, size it and give it a
/// background or border.
///
-/// ## Examples
+/// ## Examples { #examples }
/// With a block, you can give a background to content while still allowing it
/// to break across multiple pages.
/// ```example
diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs
index 0a11a751..f7117574 100644
--- a/library/src/layout/enum.rs
+++ b/library/src/layout/enum.rs
@@ -11,7 +11,7 @@ use super::GridLayouter;
///
/// Displays a sequence of items vertically and numbers them consecutively.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Automatically numbered:
/// + Preparations
@@ -47,7 +47,7 @@ use super::GridLayouter;
/// )
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This functions also has dedicated syntax:
///
/// - Starting a line with a plus sign creates an automatically numbered
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index 1e4bf40b..3c299eb0 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -34,7 +34,7 @@ use super::Sizing;
/// instead of an array. For example, `columns:` `{3}` is equivalent to
/// `columns:` `{(auto, auto, auto)}`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set text(10pt, style: "italic")
/// #let cell = rect.with(
diff --git a/library/src/layout/hide.rs b/library/src/layout/hide.rs
index a65616a0..7c954401 100644
--- a/library/src/layout/hide.rs
+++ b/library/src/layout/hide.rs
@@ -7,7 +7,7 @@ use crate::prelude::*;
/// content. It may also be useful to redact content because its arguments are
/// not included in the output.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Hello Jane \
/// #hide[Hello] Joe
diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs
index 25783d84..75fc7c3a 100644
--- a/library/src/layout/list.rs
+++ b/library/src/layout/list.rs
@@ -9,7 +9,7 @@ use super::GridLayouter;
/// Displays a sequence of items vertically, with each item introduced by a
/// marker.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// - *Content*
/// - Text
@@ -28,7 +28,7 @@ use super::GridLayouter;
/// )
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This functions also has dedicated syntax: Start a line with a hyphen,
/// followed by a space to create a list item. A list item can contain multiple
/// paragraphs and other block-level content. All content that is indented
diff --git a/library/src/layout/measure.rs b/library/src/layout/measure.rs
index 473bf5c6..c7a19243 100644
--- a/library/src/layout/measure.rs
+++ b/library/src/layout/measure.rs
@@ -8,6 +8,7 @@ use crate::prelude::*;
/// If you want to measure in the current layout dimensions, you can combined
/// `measure` and [`layout`]($func/layout).
///
+/// # Example { #example }
/// The same content can have a different size depending on the styles that
/// are active when it is layouted. For example, in the example below
/// `[#content]` is of course bigger when we increase the font size.
diff --git a/library/src/layout/pad.rs b/library/src/layout/pad.rs
index a4e79e36..c7f9ead8 100644
--- a/library/src/layout/pad.rs
+++ b/library/src/layout/pad.rs
@@ -6,7 +6,7 @@ use crate::prelude::*;
/// for each side individually, or for all sides at once by specifying a
/// positional argument.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set align(center)
///
diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs
index b9d7b03d..cb0ed7dc 100644
--- a/library/src/layout/page.rs
+++ b/library/src/layout/page.rs
@@ -14,7 +14,7 @@ use crate::prelude::*;
/// Pages can be set to use `{auto}` as their width or height. In this case,
/// the pages will grow to fit their content on the respective axis.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// >>> #set page(margin: auto)
/// #set page("us-letter")
@@ -415,7 +415,7 @@ impl PageElem {
///
/// Must not be used inside any containers.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// The next page contains
/// more details on compound theory.
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index f87b23d8..f8df63f4 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -18,7 +18,7 @@ use crate::text::{
/// properties, it can also be used to explicitly render its argument onto a
/// paragraph of its own.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set par(first-line-indent: 1em, justify: true)
/// #show par: set block(spacing: 0.65em)
@@ -203,7 +203,7 @@ pub enum Linebreaks {
/// [for loops]($scripting/#loops). Multiple consecutive
/// paragraph breaks collapse into a single one.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #for i in range(3) {
/// [Blind text #i: ]
@@ -212,7 +212,7 @@ pub enum Linebreaks {
/// }
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// Instead of calling this function, you can insert a blank line into your
/// markup to create a paragraph break.
///
diff --git a/library/src/layout/place.rs b/library/src/layout/place.rs
index 2a671628..215eb5e1 100644
--- a/library/src/layout/place.rs
+++ b/library/src/layout/place.rs
@@ -7,7 +7,7 @@ use crate::prelude::*;
/// other content in the container. Page margins will be respected.
///
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set page(height: 60pt)
/// Hello, world!
diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs
index 384995a4..646eb991 100644
--- a/library/src/layout/repeat.rs
+++ b/library/src/layout/repeat.rs
@@ -12,7 +12,7 @@ use super::AlignElem;
/// Errors if there no bounds on the available space, as it would create
/// infinite content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Sign on the dotted line:
/// #box(width: 1fr, repeat[.])
diff --git a/library/src/layout/spacing.rs b/library/src/layout/spacing.rs
index 9253c497..42d2b443 100644
--- a/library/src/layout/spacing.rs
+++ b/library/src/layout/spacing.rs
@@ -8,14 +8,14 @@ use crate::prelude::*;
/// remaining space on the line is distributed among all fractional spacings
/// according to their relative fractions.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// First #h(1cm) Second \
/// First #h(30%) Second \
/// First #h(2fr) Second #h(1fr) Third
/// ```
///
-/// ## Mathematical Spacing
+/// ## Mathematical Spacing { #math-spacing }
/// In [mathematical formulas]($category/math), you can additionally use these
/// constants to add spacing between elements: `thin`, `med`, `thick`, `quad`.
///
@@ -68,7 +68,7 @@ impl Behave for HElem {
/// the remaining space on the page is distributed among all fractional spacings
/// according to their relative fractions.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #grid(
/// rows: 3cm,
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index 80145567..2ce2cc28 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -6,7 +6,7 @@ use crate::prelude::*;
/// The stack places a list of items along an axis, with optional spacing
/// between each item.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #stack(
/// dir: ttb,
diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs
index 9cd18b56..bb24bd7c 100644
--- a/library/src/layout/table.rs
+++ b/library/src/layout/table.rs
@@ -13,7 +13,7 @@ use crate::prelude::*;
/// To give a table a caption and make it [referenceable]($func/ref), put it
/// into a [figure]($func/figure).
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #table(
/// columns: (1fr, auto, auto),
diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs
index 073b6ee2..43127d97 100644
--- a/library/src/layout/terms.rs
+++ b/library/src/layout/terms.rs
@@ -8,14 +8,14 @@ use crate::prelude::*;
/// descriptions span over multiple lines, they use hanging indent to
/// communicate the visual hierarchy.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// / Ligature: A merged glyph.
/// / Kerning: A spacing adjustment
/// between two adjacent letters.
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: Starting a line with a slash,
/// followed by a term, a colon and a description creates a term list item.
///
diff --git a/library/src/layout/transform.rs b/library/src/layout/transform.rs
index 2fb9c191..e3622ac5 100644
--- a/library/src/layout/transform.rs
+++ b/library/src/layout/transform.rs
@@ -8,7 +8,7 @@ use crate::prelude::*;
/// it at the original positions. Containers will still be sized as if the content
/// was not moved.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #rect(inset: 0pt, move(
/// dx: 6pt, dy: 6pt,
@@ -58,7 +58,7 @@ impl Layout for MoveElem {
/// Rotate an element by a given angle. The layout will act as if the element
/// was not rotated.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #stack(
/// dir: ltr,
@@ -131,7 +131,7 @@ impl Layout for RotateElem {
/// affecting the layout.
///
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set align(center)
/// #scale(x: -100%)[This is mirrored.]
diff --git a/library/src/math/accent.rs b/library/src/math/accent.rs
index 2a650f2e..7878782b 100644
--- a/library/src/math/accent.rs
+++ b/library/src/math/accent.rs
@@ -5,7 +5,7 @@ const ACCENT_SHORT_FALL: Em = Em::new(0.5);
/// Attach an accent to a base.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $grave(a) = accent(a, `)$ \
/// $arrow(a) = accent(a, arrow)$ \
diff --git a/library/src/math/attach.rs b/library/src/math/attach.rs
index f9ac4aa0..67331908 100644
--- a/library/src/math/attach.rs
+++ b/library/src/math/attach.rs
@@ -2,7 +2,7 @@ use super::*;
/// A base with optional attachments.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // With syntax.
/// $ sum_(i=0)^n a_i = 2^(1+i) $
@@ -14,7 +14,7 @@ use super::*;
/// ) $
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax for attachments after the base: Use
/// the underscore (`_`) to indicate a subscript i.e. bottom attachment and the
/// hat (`^`) to indicate a superscript i.e. top attachment.
@@ -99,7 +99,7 @@ impl LayoutMath for AttachElem {
/// Force a base to display attachments as scripts.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ scripts(sum)_1^2 != sum_1^2 $
/// ```
@@ -122,7 +122,7 @@ impl LayoutMath for ScriptsElem {
/// Force a base to display attachments as limits.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ limits(A)_1^2 != A_1^2 $
/// ```
diff --git a/library/src/math/cancel.rs b/library/src/math/cancel.rs
index 770f3c65..9a0ffb7a 100644
--- a/library/src/math/cancel.rs
+++ b/library/src/math/cancel.rs
@@ -4,7 +4,7 @@ use super::*;
///
/// This is commonly used to show the eliminiation of a term.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// >>> #set page(width: 140pt)
/// Here, we can simplify:
diff --git a/library/src/math/delimited.rs b/library/src/math/delimited.rs
index 3726aa15..a4639de6 100644
--- a/library/src/math/delimited.rs
+++ b/library/src/math/delimited.rs
@@ -8,7 +8,7 @@ pub(super) const DELIM_SHORT_FALL: Em = Em::new(0.1);
/// While matched delimiters scale by default, this can be used to scale
/// unmatched delimiters and to control the delimiter scaling more precisely.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ lr(]a, b/2]) $
/// $ lr(]sum_(x=1)^n] x, size: #50%) $
@@ -108,7 +108,7 @@ fn scale(
/// Floor an expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ floor(x/2) $
/// ```
@@ -126,7 +126,7 @@ pub fn floor(
/// Ceil an expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ ceil(x/2) $
/// ```
@@ -144,7 +144,7 @@ pub fn ceil(
/// Round an expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ round(x/2) $
/// ```
@@ -162,7 +162,7 @@ pub fn round(
/// Take the absolute value of an expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ abs(x/2) $
/// ```
@@ -181,7 +181,7 @@ pub fn abs(
/// Take the norm of an expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ norm(x/2) $
/// ```
diff --git a/library/src/math/frac.rs b/library/src/math/frac.rs
index f93ee888..0e1f78cc 100644
--- a/library/src/math/frac.rs
+++ b/library/src/math/frac.rs
@@ -4,13 +4,13 @@ const FRAC_AROUND: Em = Em::new(0.1);
/// A mathematical fraction.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ 1/2 < (x+1)/2 $
/// $ ((x+1)) / 2 = frac(a, b) $
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: Use a slash to turn neighbouring
/// expressions into a fraction. Multiple atoms can be grouped into a single
/// expression using round grouping parenthesis. Such parentheses are removed
@@ -38,7 +38,7 @@ impl LayoutMath for FracElem {
/// A binomial expression.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ binom(n, k) $
/// ```
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs
index eb465a43..84dcfd9b 100644
--- a/library/src/math/matrix.rs
+++ b/library/src/math/matrix.rs
@@ -8,7 +8,7 @@ const VERTICAL_PADDING: Ratio = Ratio::new(0.1);
///
/// Content in the vector's elements can be aligned with the `&` symbol.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ vec(a, b, c) dot vec(1, 2, 3)
/// = a + 2b + 3c $
@@ -57,7 +57,7 @@ impl LayoutMath for VecElem {
///
/// Content in cells that are in the same row can be aligned with the `&` symbol.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ mat(
/// 1, 2, ..., 10;
@@ -134,7 +134,7 @@ impl LayoutMath for MatElem {
///
/// Content across different branches can be aligned with the `&` symbol.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ f(x, y) := cases(
/// 1 "if" (x dot y)/2 <= 0,
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 21e5d805..c4c18b87 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -117,7 +117,7 @@ pub fn module() -> Module {
///
/// Can be displayed inline with text or as a separate block.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set text(font: "New Computer Modern")
///
@@ -130,7 +130,7 @@ pub fn module() -> Module {
/// $ sum_(k=1)^n k = (n(n+1)) / 2 $
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: Write mathematical markup within
/// dollar signs to create an equation. Starting and ending the equation with at
/// least one space lifts it into a separate block that is centered
diff --git a/library/src/math/op.rs b/library/src/math/op.rs
index 699d326a..1a3acaa3 100644
--- a/library/src/math/op.rs
+++ b/library/src/math/op.rs
@@ -4,14 +4,14 @@ use super::*;
/// A text operator in an equation.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ tan x = (sin x)/(cos x) $
/// $ op("custom",
/// limits: #true)_(n->oo) n $
/// ```
///
-/// ## Predefined Operators
+/// ## Predefined Operators { #predefined }
/// Typst predefines the operators `arccos`, `arcsin`, `arctan`, `arg`,
/// `cos`, `cosh`, `cot`, `ctg`, `coth`, `csc`, `deg`, `det`, `dim`,
/// `exp`, `gcd`, `hom`, `mod`, `inf`, `ker`, `lg`, `lim`, `ln`, `log`,
diff --git a/library/src/math/root.rs b/library/src/math/root.rs
index 7e00c45a..05f3a2a7 100644
--- a/library/src/math/root.rs
+++ b/library/src/math/root.rs
@@ -2,7 +2,7 @@ use super::*;
/// A square root.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ sqrt(x^2) = x = sqrt(x)^2 $
/// ```
@@ -20,7 +20,7 @@ pub fn sqrt(
/// A general root.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ root(3, x) $
/// ```
diff --git a/library/src/math/style.rs b/library/src/math/style.rs
index eb6472ee..d65058e6 100644
--- a/library/src/math/style.rs
+++ b/library/src/math/style.rs
@@ -2,7 +2,7 @@ use super::*;
/// Bold font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ bold(A) := B^+ $
/// ```
@@ -20,7 +20,7 @@ pub fn bold(
/// Upright (non-italic) font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ upright(A) != A $
/// ```
@@ -70,7 +70,7 @@ pub fn serif(
/// Sans-serif font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ sans(A B C) $
/// ```
@@ -91,7 +91,7 @@ pub fn sans(
/// Calligraphic font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Let $cal(P)$ be the set of ...
/// ```
@@ -112,7 +112,7 @@ pub fn cal(
/// Fraktur font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ frak(P) $
/// ```
@@ -133,7 +133,7 @@ pub fn frak(
/// Monospace font style in math.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ mono(x + y = z) $
/// ```
@@ -157,7 +157,7 @@ pub fn mono(
/// For uppercase latin letters, blackboard bold is additionally available
/// through [symbols]($category/symbols/sym) of the form `NN` and `RR`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ bb(b) $
/// $ bb(N) = NN $
diff --git a/library/src/math/underover.rs b/library/src/math/underover.rs
index 3ad2538c..9db79914 100644
--- a/library/src/math/underover.rs
+++ b/library/src/math/underover.rs
@@ -6,7 +6,7 @@ const BRACKET_GAP: Em = Em::new(0.25);
/// A horizontal line under content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ underline(1 + 2 + ... + 5) $
/// ```
@@ -29,7 +29,7 @@ impl LayoutMath for UnderlineElem {
/// A horizontal line over content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ overline(1 + 2 + ... + 5) $
/// ```
@@ -52,7 +52,7 @@ impl LayoutMath for OverlineElem {
/// A horizontal brace under content, with an optional annotation below.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ underbrace(1 + 2 + ... + 5, "numbers") $
/// ```
@@ -87,7 +87,7 @@ impl LayoutMath for UnderbraceElem {
/// A horizontal brace over content, with an optional annotation above.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ overbrace(1 + 2 + ... + 5, "numbers") $
/// ```
@@ -122,7 +122,7 @@ impl LayoutMath for OverbraceElem {
/// A horizontal bracket under content, with an optional annotation below.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ underbracket(1 + 2 + ... + 5, "numbers") $
/// ```
@@ -157,7 +157,7 @@ impl LayoutMath for UnderbracketElem {
/// A horizontal bracket over content, with an optional annotation above.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// $ overbracket(1 + 2 + ... + 5, "numbers") $
/// ```
diff --git a/library/src/meta/counter.rs b/library/src/meta/counter.rs
index 5c23c536..0e41a826 100644
--- a/library/src/meta/counter.rs
+++ b/library/src/meta/counter.rs
@@ -16,7 +16,7 @@ use crate::prelude::*;
/// headings, figures, and more. Moreover, you can define custom counters for
/// other things you want to count.
///
-/// ## Displaying a counter
+/// ## Displaying a counter { #displaying }
/// To display the current value of the heading counter, you call the `counter`
/// function with the `key` set to `heading` and then call the `display` method
/// on the counter. To see any output, you also have to enable heading
@@ -40,7 +40,7 @@ use crate::prelude::*;
/// #counter(heading).display("I")
/// ```
///
-/// ## Modifying a counter
+/// ## Modifying a counter { #modifying }
/// To modify a counter, you can use the `step` and `update` methods:
///
/// - The `step` method increases the value of the counter by one. Because
@@ -75,7 +75,7 @@ use crate::prelude::*;
/// Still at #counter(heading).display().
/// ```
///
-/// ## Custom counters
+/// ## Custom counters { #custom-counters }
/// To define your own counter, call the `counter` function with a string as a
/// key. This key identifies the counter globally.
///
@@ -88,7 +88,7 @@ use crate::prelude::*;
/// #mine.display() \
/// ```
///
-/// ## How to step
+/// ## How to step { #how-to-step }
/// When you define and use a custom counter, in general, you should first step
/// the counter and then display it. This way, the stepping behaviour of a
/// counter can depend on the element it is stepped for. If you were writing a
@@ -117,7 +117,7 @@ use crate::prelude::*;
/// they always start at zero. This way, they are at one for the first display
/// (which happens after the first step).
///
-/// ## Page counter
+/// ## Page counter { #page-counter }
/// The page counter is special. It is automatically stepped at each pagebreak.
/// But like other counters, you can also step it manually. For example, you
/// could have Roman page numbers for your preface, then switch to Arabic page
@@ -144,7 +144,7 @@ use crate::prelude::*;
/// Arabic numbers.
/// ```
///
-/// ## Time travel
+/// ## Time travel { #time-travel }
/// Counters can travel through time! You can find out the final value of the
/// counter before it is reached and even determine what the value was at any
/// particular location in the document.
@@ -195,7 +195,7 @@ use crate::prelude::*;
/// which one doesn't matter. After the heading follow two calls to `step()`,
/// so the final value is `{(6,)}`.
///
-/// ## Other kinds of state
+/// ## Other kinds of state { #other-state }
/// The `counter` function is closely related to [state]($func/state) function.
/// Read its documentation for more details on state management in Typst and
/// why it doesn't just use normal variables for counters.
diff --git a/library/src/meta/figure.rs b/library/src/meta/figure.rs
index fe492238..f23cbacc 100644
--- a/library/src/meta/figure.rs
+++ b/library/src/meta/figure.rs
@@ -15,7 +15,7 @@ use crate::visualize::ImageElem;
/// For example, figures containing images will be numbered separately from
/// figures containing tables.
///
-/// ## Examples
+/// ## Examples { #examples }
/// The example below shows a basic figure with an image:
/// ```example
/// @glacier shows a glacier. Glaciers
@@ -45,7 +45,7 @@ use crate::visualize::ImageElem;
/// This behaviour can be overridden by explicitly specifying the figure's
/// `kind`. All figures of the same kind share a common counter.
///
-/// ## Modifying the appearance
+/// ## Modifying the appearance { #modifying-appearance }
/// You can completely customize the look of your figures with a [show
/// rule]($styling/#show-rules). In the example below, we show the figure's
/// caption above its body and display its supplement and counter after the
diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs
index 01804edc..a5fa7441 100644
--- a/library/src/meta/heading.rs
+++ b/library/src/meta/heading.rs
@@ -24,7 +24,7 @@ use crate::text::{SpaceElem, TextElem, TextSize};
/// headings from this outline, you can set the `outlined` parameter to
/// `{false}`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set heading(numbering: "1.a)")
///
@@ -35,7 +35,7 @@ use crate::text::{SpaceElem, TextElem, TextSize};
/// To start, ...
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// Headings have dedicated syntax: They can be created by starting a line with
/// one or multiple equals signs, followed by a space. The number of equals
/// signs determines the heading's logical nesting depth.
diff --git a/library/src/meta/link.rs b/library/src/meta/link.rs
index aaf2476a..93b9999d 100644
--- a/library/src/meta/link.rs
+++ b/library/src/meta/link.rs
@@ -8,7 +8,7 @@ use crate::text::{Hyphenate, TextElem};
/// are not styled any different from normal text. However, you can easily apply
/// a style of your choice with a show rule.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #show link: underline
///
@@ -20,7 +20,7 @@ use crate::text::{Hyphenate, TextElem};
/// ]
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: Text that starts with `http://` or
/// `https://` is automatically turned into a link.
///
diff --git a/library/src/meta/numbering.rs b/library/src/meta/numbering.rs
index dc3ae987..7ba27aaa 100644
--- a/library/src/meta/numbering.rs
+++ b/library/src/meta/numbering.rs
@@ -16,7 +16,7 @@ use crate::text::Case;
/// number is substituted, their prefixes, and one suffix. The prefixes and the
/// suffix are repeated as-is.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #numbering("1.1)", 1, 2, 3) \
/// #numbering("1.a.i", 1, 2) \
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index 8e1bb723..2c51539d 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -16,7 +16,7 @@ use crate::text::{LinebreakElem, SpaceElem, TextElem};
/// be displayed in the outline alongside its title or caption. By default this
/// generates a table of contents.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #outline()
///
@@ -27,7 +27,7 @@ use crate::text::{LinebreakElem, SpaceElem, TextElem};
/// #lorem(10)
/// ```
///
-/// ## Alternative outlines
+/// ## Alternative outlines { #alternative-outlines }
/// By setting the `target` parameter, the outline can be used to generate a
/// list of other kinds of elements than headings. In the example below, we list
/// all figures containing images by setting `target` to `{figure.where(kind:
diff --git a/library/src/meta/query.rs b/library/src/meta/query.rs
index 4db658d7..ca4304b5 100644
--- a/library/src/meta/query.rs
+++ b/library/src/meta/query.rs
@@ -10,7 +10,7 @@ use crate::prelude::*;
/// find all elements, just the ones before that location, or just the ones
/// after it.
///
-/// ## Finding elements
+/// ## Finding elements { #finding-elements }
/// In the example below, we create a custom page header that displays the text
/// "Typst Academy" in small capitals and the current section title. On the
/// first page, the section title is omitted because the header is before the
@@ -62,7 +62,7 @@ use crate::prelude::*;
/// #lorem(15)
/// ```
///
-/// ## A word of caution
+/// ## A word of caution { #caution }
/// To resolve all your queries, Typst evaluates and layouts parts of the
/// document multiple times. However, there is no guarantee that your queries
/// can actually be completely resolved. If you aren't careful a query can
@@ -89,7 +89,7 @@ use crate::prelude::*;
/// })
/// ```
///
-/// ## Migration Hints
+/// ## Migration Hints { #migration-hints }
/// The `before` and `after` arguments have been removed in version 0.3.0. You
/// can now use flexible selector combinator methods instead. For example,
/// `query(heading, before: loc)` becomes `query(heading.before(loc), loc)`.
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index e4b6bbec..1f1f2b23 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -19,7 +19,7 @@ use crate::text::TextElem;
/// If you just want to link to a labelled element and not get an automatic
/// textual reference, consider using the [`link`]($func/link) function instead.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set heading(numbering: "1.")
/// #set math.equation(numbering: "(1)")
@@ -43,7 +43,7 @@ use crate::text::TextElem;
/// #bibliography("works.bib")
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: A reference to a label can be
/// created by typing an `@` followed by the name of the label (e.g.
/// `[= Introduction <intro>]` can be referenced by typing `[@intro]`).
@@ -51,7 +51,7 @@ use crate::text::TextElem;
/// To customize the supplement, add content in square brackets after the
/// reference: `[@intro[Chapter]]`.
///
-/// ## Customization
+/// ## Customization { #customization }
/// If you write a show rule for references, you can access the referenced
/// element through the `element` field of the reference. The `element` may
/// be `{none}` even if it exists if Typst hasn't discovered it yet, so you
diff --git a/library/src/meta/state.rs b/library/src/meta/state.rs
index 33c3b595..284daf54 100644
--- a/library/src/meta/state.rs
+++ b/library/src/meta/state.rs
@@ -29,7 +29,7 @@ use crate::prelude::*;
/// #compute("x - 5")
/// ```
///
-/// ## State and document markup
+/// ## State and document markup { #state-and-markup }
/// Why does it do that? Because, in general, this kind of computation with side
/// effects is problematic in document markup and Typst is upfront about that.
/// For the results to make sense, the computation must proceed in the same
@@ -60,7 +60,7 @@ use crate::prelude::*;
/// `template` function and only then sees the `Outline`. Just counting up would
/// number the `Introduction` with `1` and the `Outline` with `2`.
///
-/// ## Managing state in Typst
+/// ## Managing state in Typst { #state-in-typst }
/// So what do we do instead? We use Typst's state management system. Calling
/// the `state` function with an identifying string key and an optional initial
/// value gives you a state value which exposes a few methods. The two most
@@ -123,7 +123,7 @@ use crate::prelude::*;
/// what you want! A good example are heading counters, which is why Typst's
/// [counting system]($func/counter) is very similar to its state system.
///
-/// ## Time Travel
+/// ## Time Travel { #time-travel }
/// By using Typst's state management system you also get time travel
/// capabilities! By combining the state system with [`locate`]($func/locate)
/// and [`query`]($func/query), we can find out what the value of the state will
@@ -155,7 +155,7 @@ use crate::prelude::*;
/// #compute("x - 5")
/// ```
///
-/// ## A word of caution
+/// ## A word of caution { #caution }
/// To resolve the values of all states, Typst evaluates parts of your code
/// multiple times. However, there is no guarantee that your state manipulation
/// can actually be completely resolved.
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index 49bd3971..9bc52b61 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -6,7 +6,7 @@ use crate::prelude::*;
/// Underline text.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// This is #underline[important].
/// ```
@@ -80,7 +80,7 @@ impl Show for UnderlineElem {
/// Add a line over text.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #overline[A line over text.]
/// ```
@@ -160,7 +160,7 @@ impl Show for OverlineElem {
/// Strike through text.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// This is #strike[not] relevant.
/// ```
diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs
index fa3a99fa..5dafe4ac 100644
--- a/library/src/text/misc.rs
+++ b/library/src/text/misc.rs
@@ -28,14 +28,14 @@ impl PlainText for SpaceElem {
/// end of a paragraph is ignored, but more than one creates additional empty
/// lines.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// *Date:* 26.12.2022 \
/// *Topic:* Infrastructure Test \
/// *Severity:* High \
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: To insert a line break, simply write
/// a backslash followed by whitespace. This always creates an unjustified
/// break.
@@ -71,7 +71,7 @@ impl Behave for LinebreakElem {
///
/// Increases the current font weight by a given `delta`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// This is *strong.* \
/// This is #strong[too.] \
@@ -80,7 +80,7 @@ impl Behave for LinebreakElem {
/// And this is *evermore.*
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: To strongly emphasize content,
/// simply enclose it in stars/asterisks (`*`). Note that this only works at
/// word boundaries. To strongly emphasize part of a word, you have to use the
@@ -139,7 +139,7 @@ impl Fold for Delta {
/// - If it is already `{"italic"}` or `{"oblique"}`,
/// it turns it back to `{"normal"}`.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// This is _emphasized._ \
/// This is #emph[too.]
@@ -151,7 +151,7 @@ impl Fold for Delta {
/// This is _emphasized_ differently.
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: To emphasize content, simply
/// enclose it in underscores (`_`). Note that this only works at word
/// boundaries. To emphasize part of a word, you have to use the function.
@@ -195,7 +195,7 @@ impl Fold for Toggle {
/// Convert text or content to lowercase.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #lower("ABC") \
/// #lower[*My Text*] \
@@ -215,7 +215,7 @@ pub fn lower(
/// Convert text or content to uppercase.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #upper("abc") \
/// #upper[*my text*] \
@@ -280,7 +280,7 @@ impl Case {
/// support selecting a dedicated smallcaps font as well as synthesizing
/// smallcaps from normal letters, but this is not yet implemented.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set par(justify: true)
/// #set heading(numbering: "I.")
@@ -313,7 +313,7 @@ pub fn smallcaps(
/// the same but randomly chosen. As usual for blind texts, it does not make any
/// sense. Use it as a placeholder to try layouts.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// = Blind Text
/// #lorem(30)
diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs
index bd15cdd2..a7cf4fd7 100644
--- a/library/src/text/mod.rs
+++ b/library/src/text/mod.rs
@@ -47,7 +47,7 @@ pub(super) fn define(global: &mut Scope) {
/// rule is often the simpler choice, calling the text function directly can be
/// useful when passing text as an argument to another function.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set text(18pt)
/// With a set rule.
diff --git a/library/src/text/quotes.rs b/library/src/text/quotes.rs
index 31dbb81f..25d9cf88 100644
--- a/library/src/text/quotes.rs
+++ b/library/src/text/quotes.rs
@@ -7,7 +7,7 @@ use crate::prelude::*;
/// Automatically turns into an appropriate opening or closing quote based on
/// the active [text language]($func/text.lang).
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// "This is in quotes."
///
@@ -18,7 +18,7 @@ use crate::prelude::*;
/// "C'est entre guillemets."
/// ```
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax: The normal quote characters
/// (`'` and `"`). Typst automatically makes your quotes smart.
///
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs
index db437481..796180b4 100644
--- a/library/src/text/raw.rs
+++ b/library/src/text/raw.rs
@@ -14,7 +14,7 @@ use crate::prelude::*;
/// Displays the text verbatim and in a monospace font. This is typically used
/// to embed computer code into your document.
///
-/// ## Example
+/// ## Example { #example }
/// ````example
/// Adding `rbx` to `rcx` gives
/// the desired result.
@@ -26,7 +26,7 @@ use crate::prelude::*;
/// ```
/// ````
///
-/// ## Syntax
+/// ## Syntax { #syntax }
/// This function also has dedicated syntax. You can enclose text in 1 or 3+
/// backticks (`` ` ``) to make it raw. Two backticks produce empty raw text.
/// When you use three or more backticks, you can additionally specify a
diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs
index 4eac5897..cdf18caf 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -5,7 +5,7 @@ use crate::prelude::*;
///
/// The text is rendered smaller and its baseline is lowered.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// Revenue#sub[yearly]
/// ```
@@ -68,7 +68,7 @@ impl Show for SubElem {
///
/// The text is rendered smaller and its baseline is raised.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// 1#super[st] try!
/// ```
diff --git a/library/src/visualize/image.rs b/library/src/visualize/image.rs
index fc6aa651..071aab21 100644
--- a/library/src/visualize/image.rs
+++ b/library/src/visualize/image.rs
@@ -11,7 +11,7 @@ use crate::text::families;
///
/// Supported formats are PNG, JPEG, GIF and SVG.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #figure(
/// image("molecular.jpg", width: 80%),
diff --git a/library/src/visualize/line.rs b/library/src/visualize/line.rs
index 4a1cb87c..62a381a9 100644
--- a/library/src/visualize/line.rs
+++ b/library/src/visualize/line.rs
@@ -2,7 +2,7 @@ use crate::prelude::*;
/// A line from one point to another.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #set page(height: 100pt)
///
diff --git a/library/src/visualize/path.rs b/library/src/visualize/path.rs
index 2ef2bc1a..9b3fd876 100644
--- a/library/src/visualize/path.rs
+++ b/library/src/visualize/path.rs
@@ -4,7 +4,7 @@ use kurbo::{CubicBez, ParamCurveExtrema};
/// A path through a list of points, connected by Bezier curves.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #path(
/// fill: blue.lighten(80%),
diff --git a/library/src/visualize/polygon.rs b/library/src/visualize/polygon.rs
index ee2a6b51..2e75aff5 100644
--- a/library/src/visualize/polygon.rs
+++ b/library/src/visualize/polygon.rs
@@ -4,7 +4,7 @@ use crate::prelude::*;
///
/// The polygon is defined by its corner points and is closed automatically.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// #polygon(
/// fill: blue.lighten(80%),
diff --git a/library/src/visualize/shape.rs b/library/src/visualize/shape.rs
index 75f03f67..ca780f90 100644
--- a/library/src/visualize/shape.rs
+++ b/library/src/visualize/shape.rs
@@ -4,7 +4,7 @@ use crate::prelude::*;
/// A rectangle with optional content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // Without content.
/// #rect(width: 35%, height: 30pt)
@@ -180,7 +180,7 @@ impl Layout for RectElem {
/// A square with optional content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // Without content.
/// #square(size: 40pt)
@@ -291,7 +291,7 @@ impl Layout for SquareElem {
/// An ellipse with optional content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // Without content.
/// #ellipse(width: 35%, height: 30pt)
@@ -374,7 +374,7 @@ impl Layout for EllipseElem {
/// A circle with optional content.
///
-/// ## Example
+/// ## Example { #example }
/// ```example
/// // Without content.
/// #circle(radius: 25pt)