diff --git a/crates/typst/src/eval/module.rs b/crates/typst/src/eval/module.rs index 9f02948c9..9ae4b0f9c 100644 --- a/crates/typst/src/eval/module.rs +++ b/crates/typst/src/eval/module.rs @@ -8,9 +8,9 @@ use crate::diag::StrResult; /// An evaluated module, either built-in or resulting from a file. /// -/// You can access definitions from the module using [field access -/// notation]($scripting/#fields) and interact with it using the [import and -/// include syntaxes]($scripting/#modules). +/// You can access definitions from the module using +/// [field access notation]($scripting/#fields) and interact with it using the +/// [import and include syntaxes]($scripting/#modules). /// /// # Example /// ```example diff --git a/docs/reference/scripting.md b/docs/reference/scripting.md index 29448c721..3ac2b1dbd 100644 --- a/docs/reference/scripting.md +++ b/docs/reference/scripting.md @@ -291,13 +291,15 @@ ways: - **Import:** `{import "bar.typ"}` \ Evaluates the file at the path `bar.typ` and inserts the resulting [module]($module) into the current scope as `bar` (filename without - extension). + extension). You can use the `as` keyword to rename the imported module: + `{import "bar.typ" as baz}` - **Import items:** `{import "bar.typ": a, b}` \ Evaluates the file at the path `bar.typ`, extracts the values of the variables `a` and `b` (that need to be defined in `bar.typ`, e.g. through `{let}` - bindings) and defines them in the current file. Replacing `a, b` with `*` loads - all variables defined in a module. + bindings) and defines them in the current file. Replacing `a, b` with `*` + loads all variables defined in a module. You can use the `as` keyword to + rename the individual items: `{import "bar.typ": a as one, b as two}` Instead of a path, you can also use a [module value]($module), as shown in the following example: