Skip to main content

LaTeXImages

Struct LaTeXImages 

Source
pub struct LaTeXImages { /* private fields */ }
Expand description

LaTeX image generation processor.

Port of LaTeXML::Post::LaTeXImages.

Implementations§

Source§

impl LaTeXImages

Source

pub fn new( resource_directory: &str, resource_prefix: &str, image_type: &str, ) -> Self

Source

pub fn clean_tex(tex: &str) -> String

Clean a TeX string for image generation.

Port of LaTeXImages::cleanTeX.

Source

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.

Source

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.

Source

pub fn dvi_command(&self) -> String

Get the DVI command string.

Source

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).

Source

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).

Source

pub fn output_type(&self) -> &str

Get the output image type for the DVI method.

Source

pub fn needs_frame_output(&self) -> bool

Whether the DVI output needs frame-based cropping.

Source

pub fn pt_to_pixels(&self, pt: f64) -> f64

Convert TeX points to pixels at the configured DPI and magnification.

Source

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
Source

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.

Source

pub fn pixels_per_pt(&self) -> f64

Compute pixels-per-point for dimension conversions.

Trait Implementations§

Source§

impl Processor for LaTeXImages

Source§

fn get_name(&self) -> &str

Human-readable name for this processor.
Source§

fn resource_directory(&self) -> Option<&str>

Resource directory for generated resources (images, etc.).
Source§

fn resource_prefix(&self) -> Option<&str>

Resource prefix for generated resource filenames.
Source§

fn process(&mut self, doc: PostDocument, nodes: Vec<Node>) -> ProcessResult

Process the document given the nodes returned by to_process. Returns the resulting document(s) — splitting may produce multiple.
Source§

fn to_process(&self, doc: &PostDocument) -> Vec<Node>

Return the nodes to be processed; by default the document element. This allows processors to focus on specific kinds of nodes, or to skip processing if there are none to process.
Source§

fn desired_resource_pathname( &self, _doc: &PostDocument, _node: &Node, _source: Option<&str>, _type_ext: Option<&str>, ) -> Option<PathBuf>

Hint for a desired resource pathname.
Source§

fn generate_resource_pathname( &self, doc: &mut PostDocument, _node: &Node, _source: Option<&str>, type_ext: Option<&str>, ) -> PathBuf

Auto-generate a unique resource pathname using a counter from the doc cache.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.