2
MathML::itex2MML - Convert itex equations to MathML
7
$text = 'This is an inline equation: $\sin(\pi/2)=1$.';
9
# convert embedded itex equations to MathML:
10
$converted = itex_html_filter($text); # 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>π</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>.
13
$converted = itex_filter($text); # <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>π</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>
15
$text = '\sin(\pi/2)=1';
17
# inline equation (without the $'s)
18
$converted = itex_inline_filter($text); # <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>π</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>
20
# block equation (without the $$'s)
21
$converted = itex_block_filter($text); # <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy="false">(</mo><mi>π</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>
24
MathML::itex2MML converts itex (a dialect of LaTeX) equations into
25
MathML. Inline equations are demarcated by $..$ or \(...\). Display
26
equations are demarcated by $$...$$ or \[...\]. The syntax supported
27
is described at https://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html .
29
It is strongly suggested that you run the output through MathML::Entities,
30
to convert named entities into either numeric character references or UTF-8 characters,
31
if you intend putting the result on the Web.
33
MathML::itex2MML is based on the commandline converter, itex2MML.
36
The following functions are exported by default.
39
Converts the equations, passing the rest of the text through, unchanged.
42
Outputs just the converted equations.
45
Converts an inline equation (without the $'s).
48
Converts a block equation (without the $$'s)
52
You install MathML::itex2MML as you would install any perl module library,
53
by running these commands:
55
From the command line, type the following:
62
INSTALLATION ON WIN32 PLATFORMS
71
Jacques Distler <distler@golem.ph.utexas.edu>
74
Copyright (c) 2018 Jacques Distler. All rights reserved.
76
This library is free software; you can redistribute it and/or modify
77
it under the same terms as Perl itself.
81
<https://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html>,
82
<https://rubygems.org/gems/itextomml>