summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock3
-rw-r--r--Cargo.toml2
-rw-r--r--crates/typst-library/src/symbols.rs46
-rw-r--r--tests/ref/symbol-sect-deprecated.pngbin0 -> 391 bytes
-rw-r--r--tests/suite/symbols/symbol.typ4
5 files changed, 32 insertions, 23 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 44006cd1..21573128 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -410,7 +410,8 @@ dependencies = [
[[package]]
name = "codex"
version = "0.1.0"
-source = "git+https://github.com/typst/codex?rev=343a9b1#343a9b199430681ba3ca0e2242097c6419492d55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e0ee2092c3513f63588d51c3f81b98e6b1aa8ddcca3b5892b288f093516497d"
[[package]]
name = "color-print"
diff --git a/Cargo.toml b/Cargo.toml
index d03bfa6d..3550963e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,7 +47,7 @@ clap = { version = "4.4", features = ["derive", "env", "wrap_help"] }
clap_complete = "4.2.1"
clap_mangen = "0.2.10"
codespan-reporting = "0.11"
-codex = { git = "https://github.com/typst/codex", rev = "343a9b1" }
+codex = "0.1.0"
color-print = "0.3.6"
comemo = "0.4"
csv = "1"
diff --git a/crates/typst-library/src/symbols.rs b/crates/typst-library/src/symbols.rs
index aee7fb83..777f8172 100644
--- a/crates/typst-library/src/symbols.rs
+++ b/crates/typst-library/src/symbols.rs
@@ -10,6 +10,31 @@ use crate::foundations::{category, Category, Module, Scope, Symbol, Value};
#[category]
pub static SYMBOLS: Category;
+/// Hook up all `symbol` definitions.
+pub(super) fn define(global: &mut Scope) {
+ global.start_category(SYMBOLS);
+ extend_scope_from_codex_module(global, codex::ROOT);
+}
+
+/// Hook up all math `symbol` definitions, i.e., elements of the `sym` module.
+pub(super) fn define_math(math: &mut Scope) {
+ extend_scope_from_codex_module(math, codex::SYM);
+}
+
+fn extend_scope_from_codex_module(scope: &mut Scope, module: codex::Module) {
+ for (name, binding) in module.iter() {
+ let value = match binding.def {
+ codex::Def::Symbol(s) => Value::Symbol(s.into()),
+ codex::Def::Module(m) => Value::Module(Module::new(name, m.into())),
+ };
+
+ let scope_binding = scope.define(name, value);
+ if let Some(message) = binding.deprecation {
+ scope_binding.deprecated(message);
+ }
+ }
+}
+
impl From<codex::Module> for Scope {
fn from(module: codex::Module) -> Scope {
let mut scope = Self::new();
@@ -26,24 +51,3 @@ impl From<codex::Symbol> for Symbol {
}
}
}
-
-fn extend_scope_from_codex_module(scope: &mut Scope, module: codex::Module) {
- for (name, definition) in module.iter() {
- let value = match definition {
- codex::Def::Symbol(s) => Value::Symbol(s.into()),
- codex::Def::Module(m) => Value::Module(Module::new(name, m.into())),
- };
- scope.define(name, value);
- }
-}
-
-/// Hook up all `symbol` definitions.
-pub(super) fn define(global: &mut Scope) {
- global.start_category(SYMBOLS);
- extend_scope_from_codex_module(global, codex::ROOT);
-}
-
-/// Hook up all math `symbol` definitions, i.e., elements of the `sym` module.
-pub(super) fn define_math(math: &mut Scope) {
- extend_scope_from_codex_module(math, codex::SYM);
-}
diff --git a/tests/ref/symbol-sect-deprecated.png b/tests/ref/symbol-sect-deprecated.png
new file mode 100644
index 00000000..da647d5f
--- /dev/null
+++ b/tests/ref/symbol-sect-deprecated.png
Binary files differ
diff --git a/tests/suite/symbols/symbol.typ b/tests/suite/symbols/symbol.typ
index 4c64700a..6d2513c1 100644
--- a/tests/suite/symbols/symbol.typ
+++ b/tests/suite/symbols/symbol.typ
@@ -147,3 +147,7 @@
repr(envelope.fly),
`symbol("🖅")`.text,
)
+
+--- symbol-sect-deprecated ---
+// Warning: 5-9 `sect` is deprecated, use `inter` instead
+$ A sect B = A inter B $