diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-12-28 00:29:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-28 00:29:15 +0100 |
| commit | 9624ad635bd8adb0e421c37c63c7310ecc71a708 (patch) | |
| tree | 0062b38db54c1fd785eedecbd9b77a12800bc340 /src/library/mod.rs | |
| parent | f6c7a8292dc1ab0560408fca9d74505e9d7cf13a (diff) | |
| parent | 7f7e14d95f7240727e0163451190ff63b230e393 (diff) | |
Merge pull request #52 from typst/basicc-cols
Introduce equal-width columns
Diffstat (limited to 'src/library/mod.rs')
| -rw-r--r-- | src/library/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs index b2dd0dbe..1c97f529 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -4,6 +4,7 @@ //! definitions. mod align; +mod columns; mod flow; mod grid; mod heading; @@ -25,6 +26,7 @@ mod utility; /// Helpful imports for creating library functionality. mod prelude { pub use std::fmt::{self, Debug, Formatter}; + pub use std::num::NonZeroUsize; pub use std::rc::Rc; pub use typst_macros::properties; @@ -42,6 +44,7 @@ mod prelude { pub use self::image::*; pub use align::*; +pub use columns::*; pub use flow::*; pub use grid::*; pub use heading::*; @@ -83,6 +86,7 @@ pub fn new() -> Scope { // Break and spacing functions. std.def_func("pagebreak", pagebreak); + std.def_func("colbreak", colbreak); std.def_func("parbreak", parbreak); std.def_func("linebreak", linebreak); std.def_func("h", h); @@ -96,6 +100,7 @@ pub fn new() -> Scope { std.def_func("stack", stack); std.def_func("grid", grid); std.def_func("pad", pad); + std.def_func("columns", columns); std.def_func("align", align); std.def_func("place", place); std.def_func("move", move_); @@ -168,6 +173,15 @@ castable! { } castable! { + prelude::NonZeroUsize, + Expected: "positive integer", + Value::Int(int) => int + .try_into() + .and_then(|n: usize| n.try_into()) + .map_err(|_| "must be positive")?, +} + +castable! { String, Expected: "string", Value::Str(string) => string.into(), |
