pub struct LaTeXImages { /* private fields */ }Expand description
LaTeX image generation processor.
Port of LaTeXML::Post::LaTeXImages.
Implementations§
Source§impl LaTeXImages
impl LaTeXImages
pub fn new( resource_directory: &str, resource_prefix: &str, image_type: &str, ) -> Self
Sourcepub fn clean_tex(tex: &str) -> String
pub fn clean_tex(tex: &str) -> String
Clean a TeX string for image generation.
Port of LaTeXImages::cleanTeX.
Sourcepub fn set_tex_image(
node: &mut Node,
path: &str,
width: u32,
height: u32,
depth: Option<u32>,
)
pub fn set_tex_image( node: &mut Node, path: &str, width: u32, height: u32, depth: Option<u32>, )
Set the image attributes on a node.
Port of LaTeXImages::setTeXImage.
Sourcepub fn generate_images(
&self,
doc: &mut PostDocument,
nodes: &[Node],
extract_tex: &dyn Fn(&PostDocument, &Node) -> Option<String>,
) -> Result<(), PostError>
pub fn generate_images( &self, doc: &mut PostDocument, nodes: &[Node], extract_tex: &dyn Fn(&PostDocument, &Node) -> Option<String>, ) -> Result<(), PostError>
Generate images for the given nodes.
Port of LaTeXImages::generateImages.
This is the main pipeline entry point.
Sourcepub fn dvi_command(&self) -> String
pub fn dvi_command(&self) -> String
Get the DVI command string.
Sourcepub fn parse_log_dimensions(log_content: &str) -> Vec<Option<(f64, f64, f64)>>
pub fn parse_log_dimensions(log_content: &str) -> Vec<Option<(f64, f64, f64)>>
Parse LXIMAGE dimension lines from a LaTeX log file.
Port of the log parsing in generateImages.
Each line has format: LXIMAGE N = Wpt x Hpt + Dpt
Returns a vector indexed by image number: (width_pt, height_pt, depth_pt).
Sourcepub fn output_filename(&self, index: u32) -> String
pub fn output_filename(&self, index: u32) -> String
Compute the output filename for a given image index.
Port of sprintf($$self{dvicmd_output_name}, $index).
Sourcepub fn output_type(&self) -> &str
pub fn output_type(&self) -> &str
Get the output image type for the DVI method.
Sourcepub fn needs_frame_output(&self) -> bool
pub fn needs_frame_output(&self) -> bool
Whether the DVI output needs frame-based cropping.
Sourcepub fn pt_to_pixels(&self, pt: f64) -> f64
pub fn pt_to_pixels(&self, pt: f64) -> f64
Convert TeX points to pixels at the configured DPI and magnification.
Sourcepub fn can_process(&self) -> bool
pub fn can_process(&self) -> bool
Check whether this processor has the needed external tools.
Port of LaTeXImages::canProcess.
Checks for:
- Image processing library (ImageMagick or similar)
- LaTeX command availability
Sourcepub fn convert_image(&self, src: &str, dest: &str) -> Option<(u32, u32)>
pub fn convert_image(&self, src: &str, dest: &str) -> Option<(u32, u32)>
Convert a DVI-output image (EPS/PNG) to final format with cropping.
Port of LaTeXImages::convert_image.
For dvipng output: already cropped, just copy.
For dvips output (EPS): needs ImageMagick conversion + trim.
For dvisvgm output (SVG): already in final format.
Returns (width, height) in pixels, or None on failure.
Sourcepub fn pixels_per_pt(&self) -> f64
pub fn pixels_per_pt(&self) -> f64
Compute pixels-per-point for dimension conversions.
Trait Implementations§
Source§impl Processor for LaTeXImages
impl Processor for LaTeXImages
Source§fn resource_directory(&self) -> Option<&str>
fn resource_directory(&self) -> Option<&str>
Source§fn resource_prefix(&self) -> Option<&str>
fn resource_prefix(&self) -> Option<&str>
Source§fn process(&mut self, doc: PostDocument, nodes: Vec<Node>) -> ProcessResult
fn process(&mut self, doc: PostDocument, nodes: Vec<Node>) -> ProcessResult
to_process.
Returns the resulting document(s) — splitting may produce multiple.