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:
convert_node— convert an XMath node to the target formatraw_id_suffix— suffix for generated IDs (e.g., “.pmml”)
For parallel markup, also implement:
combine_parallel— merge primary + secondary conversions
Required Methods§
Sourcefn convert_node(
&self,
doc: &PostDocument,
xmath: &Node,
) -> Option<MathConversion>
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§
Sourcefn combine_parallel(
&self,
_doc: &PostDocument,
_xmath: &Node,
primary: MathConversion,
secondaries: Vec<MathConversion>,
) -> MathConversion
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.
Sourcefn raw_id_suffix(&self) -> &str
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.
Sourcefn is_secondary(&self) -> bool
fn is_secondary(&self) -> bool
Whether this processor is a secondary (parallel) processor.
Sourcefn parallel_secondaries(&self) -> &[Box<dyn MathProcessor>]
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.
Sourcefn id_suffix(&self) -> &str
fn id_suffix(&self) -> &str
ID suffix: empty for primary, raw_id_suffix for secondary.
Port of MathProcessor::IDSuffix.
Sourcefn can_convert(&self, _doc: &PostDocument, _math: &Node) -> bool
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.
Sourcefn preprocess(&self, _doc: &PostDocument, _nodes: &[Node])
fn preprocess(&self, _doc: &PostDocument, _nodes: &[Node])
Optional preprocessing before conversion begins.
Port of MathProcessor::preprocess.
Sourcefn outer_wrapper(
&self,
_doc: &PostDocument,
_xmath: &Node,
conversion: NodeData,
) -> NodeData
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".