Skip to main content

MathProcessor

Trait MathProcessor 

Source
pub trait MathProcessor: Processor {
    // Required method
    fn convert_node(
        &self,
        doc: &PostDocument,
        xmath: &Node,
    ) -> Option<MathConversion>;

    // Provided methods
    fn combine_parallel(
        &self,
        _doc: &PostDocument,
        _xmath: &Node,
        primary: MathConversion,
        secondaries: Vec<MathConversion>,
    ) -> MathConversion { ... }
    fn raw_id_suffix(&self) -> &str { ... }
    fn is_secondary(&self) -> bool { ... }
    fn parallel_secondaries(&self) -> &[Box<dyn MathProcessor>] { ... }
    fn id_suffix(&self) -> &str { ... }
    fn can_convert(&self, _doc: &PostDocument, _math: &Node) -> bool { ... }
    fn preprocess(&self, _doc: &PostDocument, _nodes: &[Node]) { ... }
    fn outer_wrapper(
        &self,
        _doc: &PostDocument,
        _xmath: &Node,
        conversion: NodeData,
    ) -> NodeData { ... }
}
Expand description

Abstract base trait for math-processing post-processors.

Port of LaTeXML::Post::MathProcessor.

Implementors must define:

For parallel markup, also implement:

Required Methods§

Source

fn convert_node( &self, doc: &PostDocument, xmath: &Node, ) -> Option<MathConversion>

Convert an XMath node to this processor’s format.

Port of MathProcessor::convertNode (abstract in Perl).

Provided Methods§

Source

fn combine_parallel( &self, _doc: &PostDocument, _xmath: &Node, primary: MathConversion, secondaries: Vec<MathConversion>, ) -> MathConversion

Combine parallel markup from primary conversion + secondaries.

Port of MathProcessor::combineParallel (abstract in Perl). Default implementation just returns the primary, dropping secondaries.

Source

fn raw_id_suffix(&self) -> &str

Raw ID suffix for this format (e.g., “.pmml”, “.cmml”, “.om”). Primary format returns empty string; secondaries return their suffix.

Port of MathProcessor::rawIDSuffix.

Source

fn is_secondary(&self) -> bool

Whether this processor is a secondary (parallel) processor.

Source

fn parallel_secondaries(&self) -> &[Box<dyn MathProcessor>]

Parallel-markup secondaries held by this (primary) processor. During the primary’s process_math_node, each secondary’s convert_node runs against the still-live XMath and the results are folded into one <m:semantics> via combine_parallel. Empty by default (standalone, single-format). Port of Perl MathProcessor’s primary→secondary parallel model.

Source

fn id_suffix(&self) -> &str

ID suffix: empty for primary, raw_id_suffix for secondary.

Port of MathProcessor::IDSuffix.

Source

fn can_convert(&self, _doc: &PostDocument, _math: &Node) -> bool

Whether this processor can convert the given math node. Default: always true.

Port of MathProcessor::canConvert.

Source

fn preprocess(&self, _doc: &PostDocument, _nodes: &[Node])

Optional preprocessing before conversion begins.

Port of MathProcessor::preprocess.

Source

fn outer_wrapper( &self, _doc: &PostDocument, _xmath: &Node, conversion: NodeData, ) -> NodeData

Wrap the converted XML in the appropriate outer element (e.g., m:math).

Port of MathProcessor::outerWrapper.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§