Let project previews opt into the route-D core

This commit is contained in:
gloamxun committed 2026-10-20 23:09:32 +08:00
1 parent a8e7499ce3
commit fe7fd68321
5 files changed
+59 -7

No files matched your search

+13
View File
@@ -20,6 +20,19 @@ thread_local! {
static ROUTE_D_SESSION: RefCell<Option<(Document, Engine)>> = const { RefCell::new(None) };
}
/// Build a JSON preview from the document body of a small LaTeX file.
///
/// This is the opt-in M7 bridge for v1 projects: the preamble is discarded and
/// the body is handed to the same route-D paragraph parser used by
/// `/api/route-d/preview`. The v1 semantic pipeline remains the default.
pub fn latex_preview_json(source: &str) -> Result<String, String> {
let body = source
.split_once("\\begin{document}")
.map_or(source, |(_, body)| body);
let body = body.split("\\end{document}").next().unwrap_or(body);
preview_json(body)
}
/// Build a JSON preview from blank-line-separated plain-text paragraphs.
pub fn preview_json(source: &str) -> Result<String, String> {
let paragraphs = paragraphs(source)?;