NAME

MathML::itex2MML - Convert itex to MathML

SYNOPSIS

use MathML::itex2MML;

$text    = 'This is an inline equation: $\sin(\pi/2)=1$.';

# convert embedded itex equations to MathML:
$converted = itex_html_filter($text);    # C<<< This is an inline equation: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>&pi;</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\sin(\pi/2)=1</annotation></semantics></math>. >>>

# just the equations:
$converted = itex_filter($text);    # C<<< <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>&pi;</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\sin(\pi/2)=1</annotation></semantics></math> >>>

$text    = '\sin(\pi/2)=1';

# inline equation (without the $'s)
$converted = itex_inline_filter($text);    # C<<< <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>&pi;</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\sin(\pi/2)=1</annotation></semantics></math> >>>

# block equation (without the $$'s)
$converted = itex_block_filter($text);    # C<<< <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>&pi;</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\sin(\pi/2)=1</annotation></semantics></math> >>>

DESCRIPTION

MathML::itex2MML converts itex (a dialect of LaTeX) equations into MathML. Inline equations are demarcated by $..$ or \(...\). Display equations are demarcated by $$...$$ or \[...\]. The syntax supported is described here.

It is strongly suggested that you run the output through MathML::Entities, to convert named entities into either numeric character references or UTF-8 characters, if you intend putting the result on the Web.

MathML::itex2MML is based on the commandline converter, itex2MML.

FUNCTIONS

The following functions are exported by default.

  • itex2MML_html_filter

    Take a text string, with embedded itex equations, and convert all the equations to MathML, passing through the rest of the text.

  • itex2MML_filter

    Take a text string, with embedded itex equations, and convert all the equations to MathML, dropping the rest of the text.

  • itex2MML_inline_filter

    Convert a single equation (without the enclosing $'s) to inline MathML.

  • itex2MML_block_filter

    Convert a single equation (without the enclosing $$'s) to block-display MathML.

AUTHOR

Jacques Distler <distler@golem.ph.utexas.edu>

COPYRIGHT

Copyright (c) 2018 Jacques Distler. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

MathML::Entitities

https://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html

https://rubygems.org/gems/itextomml