diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-19 20:49:01 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-19 20:49:01 +0200 |
| commit | 77dac270a8a99f24a6fc0eb9e92256bcc07c586c (patch) | |
| tree | 8e240b798a5c1aabd77c823e65828f3c6d2557f1 /src/library/mod.rs | |
| parent | 6d7e7d945b315469b80bca3466a96534b2a17639 (diff) | |
Make compute functions possible 💻
Ships with the amazing new `rgb` function!
Diffstat (limited to 'src/library/mod.rs')
| -rw-r--r-- | src/library/mod.rs | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs index eaab72fc..7d266eb5 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -2,12 +2,14 @@ mod align; mod boxed; +mod color; mod font; mod page; mod spacing; pub use align::*; pub use boxed::*; +pub use color::*; pub use font::*; pub use page::*; pub use spacing::*; @@ -18,10 +20,10 @@ use crate::compute::scope::Scope; use crate::prelude::*; macro_rules! std { - (fallback: $fallback:expr $(, $name:literal => $func:expr)* $(,)?) => { + ($($name:literal => $func:expr),* $(,)?) => { /// Create a scope with all standard library functions. pub fn _std() -> Scope { - let mut std = Scope::new(wrap!(val)); + let mut std = Scope::new(); $(std.insert($name, wrap!($func));)* std } @@ -35,32 +37,12 @@ macro_rules! wrap { } std! { - fallback: val, "align" => align, "box" => boxed, - "dump" => dump, "font" => font, "h" => h, "page" => page, "pagebreak" => pagebreak, + "rgb" => rgb, "v" => v, - "val" => val, -} - -/// `val`: Layouts its body flatly, ignoring other arguments. -/// -/// This is also the fallback function, which is used when a function name -/// cannot be resolved. -pub async fn val(_: Span, mut args: TableValue, _: LayoutContext<'_>) -> Pass<Value> { - let commands = match args.take::<SyntaxTree>() { - Some(tree) => vec![LayoutSyntaxTree(tree)], - None => vec![], - }; - - Pass::commands(commands, Feedback::new()) -} - -/// `dump`: Dumps its arguments into the document. -pub async fn dump(_: Span, args: TableValue, _: LayoutContext<'_>) -> Pass<Value> { - Pass::okay(Value::Table(args)) } |
