bzr branch
http://golem.ph.utexas.edu/~distler/code/itexToMML/
|
82
by Jacques Distler
Perl bindings |
1 |
NAME |
2 |
MathML::itex2MML - Convert itex equations to MathML |
|
3 |
||
4 |
SYNOPSIS |
|
5 |
use MathML::itex2MML; |
|
6 |
||
7 |
$text = 'This is an inline equation: $\sin(\pi/2)=1$.'; |
|
8 |
||
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>. |
|
11 |
||
12 |
# just the equations: |
|
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> |
|
14 |
||
15 |
$text = '\sin(\pi/2)=1'; |
|
16 |
||
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> |
|
19 |
||
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> |
|
22 |
||
23 |
DESCRIPTION |
|
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 . |
|
28 |
||
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. |
|
32 |
||
33 |
MathML::itex2MML is based on the commandline converter, itex2MML. |
|
34 |
||
35 |
FUNCTIONS |
|
36 |
The following functions are exported by default. |
|
37 |
||
38 |
* itex_html_filter |
|
39 |
Converts the equations, passing the rest of the text through, unchanged. |
|
40 |
||
41 |
* itex_filter |
|
42 |
Outputs just the converted equations. |
|
43 |
||
44 |
* itex_inline_filter |
|
45 |
Converts an inline equation (without the $'s). |
|
46 |
||
47 |
* itex_block_filter |
|
48 |
Converts a block equation (without the $$'s) |
|
49 |
||
50 |
INSTALLATION ON UNIX |
|
51 |
||
52 |
You install MathML::itex2MML as you would install any perl module library, |
|
53 |
by running these commands: |
|
54 |
||
55 |
From the command line, type the following: |
|
56 |
||
57 |
> perl Makefile.PL |
|
58 |
> make |
|
59 |
> make test |
|
60 |
> make install |
|
61 |
||
62 |
INSTALLATION ON WIN32 PLATFORMS |
|
63 |
||
64 |
> perl Makefile.PL |
|
65 |
> nmake |
|
66 |
> nmake test |
|
67 |
> nmake install |
|
68 |
||
69 |
||
70 |
AUTHOR |
|
71 |
Jacques Distler <distler@golem.ph.utexas.edu> |
|
72 |
||
73 |
COPYRIGHT |
|
74 |
Copyright (c) 2018 Jacques Distler. All rights reserved. |
|
75 |
||
76 |
This library is free software; you can redistribute it and/or modify |
|
77 |
it under the same terms as Perl itself. |
|
78 |
||
79 |
SEE ALSO |
|
80 |
MathML::Entities, |
|
81 |
<https://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html>, |
|
82 |
<https://rubygems.org/gems/itextomml> |
|
83 |