latexml/lib.rs
1// Macros (DefMacro!, load_model!, …) live in latexml_engine since the
2// extraction; latexml_package is a regular dep (its prelude is `use`d
3// from binding files, not macros).
4#[macro_use]
5extern crate latexml_engine;
6extern crate latexml_package;
7
8pub mod api;
9pub mod bib_session;
10pub mod converter;
11pub mod core_interface;
12pub mod identity;
13pub mod ini_tex;
14pub mod lsp_server;
15pub mod main_tex;
16pub mod multidoc;
17pub mod post;
18pub mod render_workers;
19pub mod util;
20
21/// Load the embedded LaTeXML schema (compile-time) into the runtime
22/// `MODEL`. Single home for the `load_model!("LaTeXML")` macro
23/// expansion — the macro generates a fresh `_ModelLoader::build_model`
24/// at each call site (~600 KiB of `.text` per copy), so funnelling
25/// all callers through this one function lets LTO keep exactly one
26/// instance in the final binary. Mirrors Perl
27/// `LaTeXML::Common::Model::compileSchema` (Model.pm L121-136).
28pub fn load_latexml_default_model() {
29 use latexml_codegen::LoadModel;
30 load_model!("LaTeXML");
31}
32
33/// Load the embedded LaTeXML schema and return its compiled-model
34/// serialisation in the `.model` plain-text format. Used by
35/// `tools/compileschema.sh` stage 2 (and the `--dump-model` flag on
36/// the `latexml_oxide` binary) to regenerate `LaTeXML.model` from the
37/// same source the runtime sees.
38pub fn dump_compiled_latexml_model() -> String {
39 load_latexml_default_model();
40 latexml_core::common::model::MODEL
41 .borrow()
42 .dump_compiled_schema()
43}