Skip to content

Commit

Permalink
refactor: only expose djot::parse that immediately transforms to IR
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed May 20, 2024
1 parent c71b810 commit ae4d851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/djot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Context {
}
}

pub fn djot_to_ir<'s>(mut djot: impl Iterator<Item = Event<'s>>) -> impl Iterator<Item = IrEvent<'s>> {
fn djot_to_ir<'s>(mut djot: impl Iterator<Item = Event<'s>>) -> impl Iterator<Item = IrEvent<'s>> {
let mut ctx = Context::new();

// to be replaced by `gen`-blocks
Expand Down Expand Up @@ -629,6 +629,10 @@ pub fn djot_to_ir<'s>(mut djot: impl Iterator<Item = Event<'s>>) -> impl Iterato
.into_iter()
}

pub fn parse<'s>(input: &'s str) -> impl Iterator<Item = IrEvent<'s>> {
djot_to_ir(jotdown::Parser::new(input))
}

#[cfg(test)]
mod test {
use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn build(ctx: &Ctx, path: &Path, renderer: &render::Renderer) -> anyhow::Result<

let mut parsed: Vec<Vec<ir_markup::Event<'_>>> = content
.par_iter()
.map(|content| djot::djot_to_ir(jotdown::Parser::new(content)).collect())
.map(|content| djot::parse(content).collect())
.collect();

// Parse entry front matter, consuming the front matter events from `parsed`
Expand Down

0 comments on commit ae4d851

Please sign in to comment.