summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-24 17:51:07 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-24 17:51:07 +0100
commit96f72eee6c6b595164c7a0576c407d7a590661db (patch)
treed212f57faf3e919937921884a75bf45efb02f4ae /src
parent8d3c68a1deb28dce2b80ed61f85141180ce6a951 (diff)
Separate typesetting and compilation
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs12
-rw-r--r--src/model/mod.rs2
-rw-r--r--src/model/typeset.rs17
3 files changed, 24 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 75200144..4607cd0c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -49,16 +49,16 @@ use comemo::{Prehashed, Track};
use crate::diag::{FileResult, SourceResult};
use crate::font::{Font, FontBook};
use crate::frame::Frame;
-use crate::model::{Library, Route, StyleChain};
+use crate::model::{Library, Route};
use crate::syntax::{Source, SourceId};
use crate::util::Buffer;
-/// Typeset a source file into a collection of layouted frames.
+/// Compile a source file into a collection of layouted frames.
///
/// Returns either a vector of frames representing individual pages or
/// diagnostics in the form of a vector of error message with file and span
/// information.
-pub fn typeset(
+pub fn compile(
world: &(dyn World + 'static),
source: &Source,
) -> SourceResult<Vec<Frame>> {
@@ -66,10 +66,8 @@ pub fn typeset(
let route = Route::default();
let module = model::eval(world.track(), route.track(), source)?;
- // Layout the module's contents.
- let library = world.library();
- let styles = StyleChain::with_root(&library.styles);
- (library.items.layout)(&module.content, world.track(), styles)
+ // Typeset the module's contents.
+ model::typeset(world.track(), &module.content)
}
/// The environment in which typesetting occurs.
diff --git a/src/model/mod.rs b/src/model/mod.rs
index 93e33d5c..f5c1e6dd 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -21,6 +21,7 @@ mod func;
mod methods;
mod ops;
mod scope;
+mod typeset;
mod vm;
#[doc(hidden)]
@@ -38,5 +39,6 @@ pub use self::library::*;
pub use self::scope::*;
pub use self::str::*;
pub use self::styles::*;
+pub use self::typeset::*;
pub use self::value::*;
pub use self::vm::*;
diff --git a/src/model/typeset.rs b/src/model/typeset.rs
new file mode 100644
index 00000000..2026bf99
--- /dev/null
+++ b/src/model/typeset.rs
@@ -0,0 +1,17 @@
+use comemo::Tracked;
+
+use super::{Content, StyleChain};
+use crate::diag::SourceResult;
+use crate::frame::Frame;
+use crate::World;
+
+/// Typeset content into a collection of layouted frames.
+///
+/// Returns either a vector of frames representing individual pages or
+/// diagnostics in the form of a vector of error message with file and span
+/// information.
+pub fn typeset(world: Tracked<dyn World>, content: &Content) -> SourceResult<Vec<Frame>> {
+ let library = world.library();
+ let styles = StyleChain::with_root(&library.styles);
+ (library.items.layout)(content, world, styles)
+}