forked from typst/typst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
145 additions
and
2,647 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//! Modifiable symbols. | ||
use crate::foundations::{category, Category, Module, Scope, Symbol, Value}; | ||
|
||
/// These two modules give names to symbols and emoji to make them easy to | ||
/// insert with a normal keyboard. Alternatively, you can also always directly | ||
/// enter Unicode symbols into your text and formulas. In addition to the | ||
/// symbols listed below, math mode defines `dif` and `Dif`. These are not | ||
/// normal symbol values because they also affect spacing and font style. | ||
#[category] | ||
pub static SYMBOLS: Category; | ||
|
||
impl From<codex::Module> for Scope { | ||
fn from(module: codex::Module) -> Scope { | ||
let mut scope = Self::new(); | ||
extend_scope_from_codex_module(&mut scope, module); | ||
scope | ||
} | ||
} | ||
|
||
impl From<codex::Symbol> for Symbol { | ||
fn from(symbol: codex::Symbol) -> Self { | ||
match symbol { | ||
codex::Symbol::Single(c) => Symbol::single(c), | ||
codex::Symbol::Multi(list) => Symbol::list(list), | ||
} | ||
} | ||
} | ||
|
||
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.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); | ||
} |
Oops, something went wrong.