diff --git a/crates/typst-library/src/lib.rs b/crates/typst-library/src/lib.rs index 03e964412..da31409aa 100644 --- a/crates/typst-library/src/lib.rs +++ b/crates/typst-library/src/lib.rs @@ -44,6 +44,7 @@ fn global(math: Module) -> Module { /// Defines scoped values that are globally available, too. fn prelude(global: &mut Scope) { + global.reset_category(); global.define("black", Color::BLACK); global.define("gray", Color::GRAY); global.define("silver", Color::SILVER); diff --git a/crates/typst/src/eval/scope.rs b/crates/typst/src/eval/scope.rs index 35ff202a4..85bef53ab 100644 --- a/crates/typst/src/eval/scope.rs +++ b/crates/typst/src/eval/scope.rs @@ -109,6 +109,11 @@ impl Scope { self.category = Some(name); } + /// Reset the category. + pub fn reset_category(&mut self) { + self.category = None; + } + /// Bind a value to a name. #[track_caller] pub fn define(&mut self, name: impl Into, value: impl IntoValue) { diff --git a/crates/typst/src/geom/color.rs b/crates/typst/src/geom/color.rs index b99ba83d1..93d0a31f4 100644 --- a/crates/typst/src/geom/color.rs +++ b/crates/typst/src/geom/color.rs @@ -20,10 +20,10 @@ type Luma = palette::luma::Luma; /// A color in a specific color space. /// /// Typst supports: -/// - sRGB through the [`rgb` function]($rgb) -/// - Device CMYK through [`cmyk` function]($cmyk) -/// - D65 Gray through the [`luma` function]($luma) -/// - Oklab through the [`oklab` function]($oklab) +/// - sRGB through the [`rgb` function]($color.rgb) +/// - Device CMYK through [`cmyk` function]($color.cmyk) +/// - D65 Gray through the [`luma` function]($color.luma) +/// - Oklab through the [`oklab` function]($color.oklab) /// - Linear RGB through the [`color.linear-rgb` function]($color.linear-rgb) /// - HSL through the [`color.hsl` function]($color.hsl) /// - HSV through the [`color.hsv` function]($color.hsv) @@ -181,7 +181,7 @@ impl Color { /// This color space is similar to Srgb, but with the distinction that /// the color component are not gamma corrected. This makes it easier to /// perform color operations such as blending and interpolation. Although, - /// you should prefer to use the [`oklab` function]($oklab) for these. + /// you should prefer to use the [`oklab` function]($color.oklab) for these. /// /// A linear RGB(A) color is represented internally by an array of four components: /// - red ([`ratio`]($ratio)) diff --git a/docs/changelog.md b/docs/changelog.md index 15ba4d781..262908753 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -515,7 +515,7 @@ description: | - Added [`zip`]($array.zip), [`sum`]($array.sum), and [`product`]($array.product) methods for arrays - Added `fact`, `perm`, `binom`, `gcd`, `lcm`, `atan2`, `quo`, `trunc`, and - `fract` [calculation]($category/calculate) + `fract` [calculation]($category/foundations/calc) functions - Improvements - Text in SVGs now displays properly diff --git a/docs/guides/guide-for-latex-users.md b/docs/guides/guide-for-latex-users.md index 1ed839a85..ed3170ff5 100644 --- a/docs/guides/guide-for-latex-users.md +++ b/docs/guides/guide-for-latex-users.md @@ -143,11 +143,11 @@ And finally a little loop: ``` A function call always involves the name of the function ([`rect`]($rect), -[`underline`]($underline), [`calc.max`]($calc.max), [`range`]($range)) followed -by parentheses (as opposed to LaTeX where the square brackets and curly braces -are optional if the macro requires no arguments). The expected list of arguments -passed within those parentheses depends on the concrete function and is -specified in the [reference]($reference). +[`underline`]($underline), [`calc.max`]($calc.max), [`range`]($array.range)) +followed by parentheses (as opposed to LaTeX where the square brackets and curly +braces are optional if the macro requires no arguments). The expected list of +arguments passed within those parentheses depends on the concrete function and +is specified in the [reference]($reference). ### Arguments A function can have multiple arguments. Some arguments are positional, i.e., you