From ae4d851c0683a41c838694af553838022356e951 Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Mon, 20 May 2024 12:17:29 +0200 Subject: [PATCH] refactor: only expose djot::parse that immediately transforms to IR --- src/djot.rs | 6 +++++- src/main.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/djot.rs b/src/djot.rs index d5a4a31..2e49d4c 100644 --- a/src/djot.rs +++ b/src/djot.rs @@ -111,7 +111,7 @@ impl Context { } } -pub fn djot_to_ir<'s>(mut djot: impl Iterator>) -> impl Iterator> { +fn djot_to_ir<'s>(mut djot: impl Iterator>) -> impl Iterator> { let mut ctx = Context::new(); // to be replaced by `gen`-blocks @@ -629,6 +629,10 @@ pub fn djot_to_ir<'s>(mut djot: impl Iterator>) -> impl Iterato .into_iter() } +pub fn parse<'s>(input: &'s str) -> impl Iterator> { + djot_to_ir(jotdown::Parser::new(input)) +} + #[cfg(test)] mod test { use std::collections::HashMap; diff --git a/src/main.rs b/src/main.rs index 3cab45f..7c27693 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,7 +152,7 @@ fn build(ctx: &Ctx, path: &Path, renderer: &render::Renderer) -> anyhow::Result< let mut parsed: Vec>> = 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`