summaryrefslogtreecommitdiff
path: root/library/src/lib.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-23 15:58:59 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-23 16:07:54 +0100
commit5ae81971f299688b05d77af208d7bb44ffce5e2d (patch)
tree35b914f9bdf5565d4602c4bdda08ccbc30977df4 /library/src/lib.rs
parentb2a3d3f235fb5a23322435b854460f52db772114 (diff)
Introduce `Library`
Diffstat (limited to 'library/src/lib.rs')
-rw-r--r--library/src/lib.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/library/src/lib.rs b/library/src/lib.rs
index e5e60968..7fcad183 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -10,12 +10,17 @@ pub mod structure;
pub mod text;
use typst::geom::{Align, Color, Dir, GenAlign};
-use typst::model::{LangItems, Node, NodeId, Scope, StyleMap};
+use typst::model::{LangItems, Library, Node, NodeId, Scope, StyleMap};
use self::layout::LayoutRoot;
-/// Construct the standard library scope.
-pub fn scope() -> Scope {
+/// Construct the standard library.
+pub fn new() -> Library {
+ Library { scope: scope(), styles: styles(), items: items() }
+}
+
+/// Construct the standard scope.
+fn scope() -> Scope {
let mut std = Scope::new();
// Text.
@@ -147,12 +152,12 @@ pub fn scope() -> Scope {
}
/// Construct the standard style map.
-pub fn styles() -> StyleMap {
+fn styles() -> StyleMap {
StyleMap::new()
}
/// Construct the standard lang item mapping.
-pub fn items() -> LangItems {
+fn items() -> LangItems {
LangItems {
layout: |content, world, styles| content.layout_root(world, styles),
em: |styles| styles.get(text::TextNode::SIZE),