Skip to main content

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 ini_tex;
13pub mod lsp_server;
14pub mod main_tex;
15pub mod post;
16pub mod render_workers;
17pub mod util;
18
19/// Load the embedded LaTeXML schema (compile-time) into the runtime
20/// `MODEL`. Single home for the `load_model!("LaTeXML")` macro
21/// expansion — the macro generates a fresh `_ModelLoader::build_model`
22/// at each call site (~600 KiB of `.text` per copy), so funnelling
23/// all callers through this one function lets LTO keep exactly one
24/// instance in the final binary. Mirrors Perl
25/// `LaTeXML::Common::Model::compileSchema` (Model.pm L121-136).
26pub fn load_latexml_default_model() {
27  use latexml_codegen::LoadModel;
28  load_model!("LaTeXML");
29}
30
31/// Load the embedded LaTeXML schema and return its compiled-model
32/// serialisation in the `.model` plain-text format. Used by
33/// `tools/compileschema.sh` stage 2 (and the `--dump-model` flag on
34/// the `latexml_oxide` binary) to regenerate `LaTeXML.model` from the
35/// same source the runtime sees.
36pub fn dump_compiled_latexml_model() -> String {
37  load_latexml_default_model();
38  latexml_core::common::model::MODEL
39    .borrow()
40    .dump_compiled_schema()
41}