diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-10 23:36:17 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-10 23:38:03 +0200 |
| commit | 8f788f9a4f5e970bbe6147987b711470d57aca8d (patch) | |
| tree | cc89008dfdfc62ecf4eb2517d92ec7c7095fa573 /src/library/mod.rs | |
| parent | 61470fba68e9f19b481034427add5f3d8cfbc0a8 (diff) | |
Add standard `align` function and support right-alignment ➡️
Diffstat (limited to 'src/library/mod.rs')
| -rw-r--r-- | src/library/mod.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs new file mode 100644 index 00000000..9323c4c0 --- /dev/null +++ b/src/library/mod.rs @@ -0,0 +1,34 @@ +//! The standard library for the _Typst_ language. + +use crate::func::Scope; + +mod align; +mod styles; + +/// Useful imports for creating your own functions. +pub mod prelude { + pub use crate::syntax::{SyntaxTree, FuncHeader, Expression}; + pub use crate::parsing::{parse, ParseContext, ParseResult, ParseError}; + pub use crate::layout::{layout, Layout, LayoutContext, LayoutResult, LayoutError}; + pub use crate::layout::flex::FlexLayout; + pub use crate::layout::boxed::BoxLayout; + pub use crate::func::Function; + + pub fn err<S: Into<String>, T>(message: S) -> ParseResult<T> { + Err(ParseError::new(message)) + } +} + +pub use align::AlignFunc; +pub use styles::{ItalicFunc, BoldFunc, MonospaceFunc}; + + +/// Create a scope with all standard functions. +pub fn std() -> Scope { + let mut std = Scope::new(); + std.add::<BoldFunc>("bold"); + std.add::<ItalicFunc>("italic"); + std.add::<MonospaceFunc>("mono"); + std.add::<AlignFunc>("align"); + std +} |
