Skip to main content

Module writer

Module writer 

Source
Expand description

XML/HTML output sink — port of LaTeXML::Post::Writer.

Two related concerns live here:

  1. The Writer post-processor (last in the chain) that serializes a PostDocument to its destination, handling DOCTYPE removal, TEMPORARY_DOCUMENT_ID cleanup, and HTML vs XML serialization.
  2. Free-standing helpers (write_output, ensure_parent_dir) used by binary main()s that already have the serialized string in hand (post-processing returns a String) and need to route it to a destination path or stdout. Replaces the duplicated File::create + write! + ensure_parent_dir boilerplate that used to live in latexml_oxide.rs (and the now-retired latexmlpost_oxide.rs).

Companion module: crate::pack (the LaTeXML::Post::Pack analog) handles archive bundling when the destination is a zip.

Structs§

Writer
Writer post-processor: serializes document to file.

Enums§

OutputFormat
Output format for the writer.

Functions§

ensure_parent_dir
Ensure the parent directory of path exists, creating it (and any missing ancestors) as needed. No-op when path has no parent or the parent is the current directory.
write_output
Write the serialized output content to dest if Some, else to stdout. Creates parent directories as needed.
write_output_segments
Like write_output but writes several segments back-to-back without concatenating them into one buffer first. Used for the conversion log, where the core and post-phase segments are each already-allocated and large for real articles — a format!("{core}{post}") would allocate a third copy of their combined size on the conversion hot path. Segments are written verbatim and in order through a single BufWriter (one file open/truncate); insert any separators (e.g. "\n") as their own segments.