Bump codex to 0.1.0 (#5805)

This commit is contained in:
Laurenz 2025-02-04 11:08:43 +01:00 committed by GitHub
parent 73ffbdef2b
commit 0ea668077d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 23 deletions

3
Cargo.lock generated
View File

@ -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"

View File

@ -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"

View File

@ -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);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

View File

@ -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 $