Skip to main content

Module extract

Module extract 

Source
Expand description

Document-subtree extraction helpers — port of LaTeXML::Util::Pack’s get_math and get_embeddable (Perl Pack.pm L247-313).

These are the implementations behind the --whatsout fragment and --whatsout math CLI modes. They run AFTER all post-processing on the final XML/HTML document and return the subtree the user actually wanted (an embeddable inline snippet, or just the math). The --whatsout archive mode keeps the full document (no extraction) but flags the caller to wrap it into a zip — see Whatsout::is_archive and crate::pack::pack_archive.

Companion modules:

§What’s not ported (intentional gaps)

Perl get_math falls through to inline an SVG when the math node’s imagesrc ends in .svg — for our pipeline the SVG is already a referenced resource bundled by pack_archive, so the inline path has no caller. Doc string flags the gap so a future visitor knows it’s intentional.

Perl get_embeddable copies namespace declarations and RDFa attributes from the document root onto the extracted node. libxml-rs exposes Node::set_attribute for the RDFa half cheaply; namespace re-binding requires FFI into xmlSetNs and is deferred (the extracted subtree usually inherits its namespaces fine as long as the consumer doesn’t re-parse it standalone).

Enums§

Whatsout
Output extraction mode — port of Perl LaTeXML::Util::Pack’s whatsout option (Pack.pm L320-345). Selects which subtree of the post-processed document to serialize and ship to the user.

Functions§

get_embeddable
Extract an embeddable HTML fragment from a post-processed document, mirroring Perl LaTeXML::Util::Pack::get_embeddable (Pack.pm L282-313).
get_math
Extract the math subtree(s) from a post-processed document, mirroring Perl LaTeXML::Util::Pack::get_math (Pack.pm L247-280).
serialize_whatsout
Apply the requested Whatsout extraction to doc and return the serialized subtree. Returns the full document for Whatsout::Document (the default no-op) or when extraction finds no candidate node.