Files
craft-libs/crates/math/tests/corpus/latex.tsv
T
Dylan M. Taylorandshuff57 85b4dabf0f Add craft-math: equations as one tree with OMML, MathML, LaTeX and UnicodeMath (#1013)
* Add craft-math: the equation tree with OMML, MathML, LaTeX and UnicodeMath

The math tree, LaTeX, linear-format, symbol and tree-walk modules come
from craft-wordmodel (storytold/craft-libs#963, WordCraft's crates/doc at
07f97737) unchanged, with the run colour (Rgb) and the symbol-font tables
they use. MathML is WordCraft's crates/formats/src/mathml.rs and OMML is
WordCraft's crates/docx/src/read/math.rs and write/math.rs (06c2ae6f /
07f97737), moved onto craft-xml. The HTML-specific MathML tests stay in
WordCraft; the rest moved with the code.

mathml::parse and omml::parse/read_str/write_str are new: string entry
points for callers that have no tree of their own.

* craft-math: read MathLive's and other spellings of LaTeX math commands

\abs{...} (an absolute value), \lvert \rvert \lVert \rVert, \nparallel,
\backprime, \infinity, \cross, \differentialD, \exponentialE and
\imaginaryI (MathLive's d, upright e and i), \emph, \textsf, \hbox,
\mathnormal and \underleftarrow / \underrightarrow /
\underleftrightarrow were unknown and read as literal text. They are read
as equaSHion's typed-input parser reads them (storytold/craft-libs#29).

* craft-math: equaSHion's equation corpus as test data

corpus/equations.tsv, corpus/latex.tsv and the OMML samples of
storytold/craft-libs#29 (7a6ef6b9), unmodified.

* craft-math: corpus round trips, GridCraft's OMML cases, entry points and limits tested; README

The corpus equations go through OMML, MathML and LaTeX and back; the OMML
samples are written back as kept and from the tree. GridCraft's OMML to
LaTeX test cases (crates/xlsx/src/omml.rs) give LaTeX that reads back the
same through the tree. omml::parse and read_str are tested against other
prefixes, the strict namespace, kept OMML, junk, the element cap and deep
nesting.

---------

Co-authored-by: shuff57 <62350898+shuff57@users.noreply.github.com>
2026-11-11 20:31:02 -05:00

2.7 KiB

1# input (MathLive-style LaTeX)to_latex(from_linear(input))
2x^2x^2
3x^{2}x^2
4x^{2+1}x^{2+1}
5x^{n^{2}}x^{n^2}
6x^2+3x-2x^2+3x-2
72x2x
83x^2+2x-13x^2+2x-1
9\frac{1}{x}\frac{1}{x}
10\frac{x+1}{x-1}\frac{x+1}{x-1}
11\frac{\frac{1}{2}}{3}\frac{\frac{1}{2}}{3}
12\frac{x^{2}}{3}\frac{x^2}{3}
13\sqrt{x}\sqrt{x}
14\sqrt{x+1}\sqrt{x+1}
15\sqrt[3]{x}\sqrt[3]{x}
16\sqrt{\sqrt{x}}\sqrt{\sqrt{x}}
17\sin(x)\sin\left(x\right)
18\sin x\sin\left(x\right)
19\sin{x}\sin\left(x\right)
20\cos\left(x\right)\cos\left(x\right)
21\sin\left(2x\right)+\cos(x)\sin\left(2x\right)+\cos\left(x\right)
22\tan(x)\tan\left(x\right)
23\arcsin(x)\arcsin\left(x\right)
24\sinh(x)\sinh\left(x\right)
25\ln(x)\ln\left(x\right)
26\ln x\ln\left(x\right)
27\log(x)\log\left(x\right)
28\exp(x)\exp\left(x\right)
29\abs{x}\left|x\right|
30|x|\left|x\right|
31|x-1|+|x+1|\left|x-1\right|+\left|x+1\right|
322\pi x2\pi x
33\sin(\pi x)\sin\left(\pi x\right)
34\theta\theta
351+\cos\theta1+\cos\left(\theta\right)
36\infty\infty
37\mathrm{e}^{x}\mathrm{e}^x
38x_1+x_{12}x_1+x_{12}
392\cdot32\cdot3
402\times32\times3
414\div24\div2
42x\pm1x\pm1
43(x+1)(x-1)\left(x+1\right)\left(x-1\right)
44(x+1)2\left(x+1\right)2
452(x+1)2\left(x+1\right)
46x^2+y^2-1x^2+y^2-1
47x--1x--1
48x++1x++1
493\sqrt{x}3\sqrt{x}
50e^{-x^2}e^{-x^2}
51\frac{\sin(x)}{x}\frac{\sin\left(x\right)}{x}
52\left|x\right|\left|x\right|
53\cot(x)\sec(x)\csc(x)\cot\left(x\right)\sec\left(x\right)\csc\left(x\right)
542\sin(3x)2\sin\left(3x\right)
55\sin^{2}(x)\sin^2\left(x\right)
56\sqrt[n]{x+1}\sqrt[n]{x+1}
57a ba b
58\frac{1}{2}x\frac{1}{2}x
59x^{\frac{1}{2}}x^{\frac{1}{2}}
60\sin\theta\sin\left(\theta\right)
6110x10x
622.5x2.5x
63(2)(3)(4)\left(2\right)\left(3\right)\left(4\right)
64\operatorname{abs}(x)\operatorname{abs}\left(x\right)
65\frac{1}{}\frac{1}{}
66\arctan(x)^{2}{\arctan\left(x\right)}^2
67\cosh x\cosh\left(x\right)
68\tanh(x)\tanh\left(x\right)
69x^{2}_{3}x_3^2
70x^2+y^2=25x^2+y^2=25
71y=\frac{x^2-1}{x+1}y=\frac{x^2-1}{x+1}
72y=\sqrt{4-x^2}y=\sqrt{4-x^2}
73r=1+\cos\thetar=1+\cos\left(\theta\right)
74\left(x-2\right)^2+\left(y+1\right)^2=9\left(x-2\right)^2+\left(y+1\right)^2=9
75y=\left|x-3\right|+2y=\left|x-3\right|+2
76y=\sin\left(2x\right)\cos\left(x\right)y=\sin\left(2x\right)\cos\left(x\right)
77y=\frac{1}{2}x+\frac{3}{4}y=\frac{1}{2}x+\frac{3}{4}
78y=e^{x}y=e^x
79y=\ln\left(x+1\right)y=\ln\left(x+1\right)
80y=\sqrt[3]{x^2}y=\sqrt[3]{x^2}
81f\left(x\right)=ax^2+bx+cf\left(x\right)=ax^2+bx+c
82\frac{d}{dx}x^2\frac{d}{dx}x^2
83y=2^{x}y=2^x
84y=x^{\frac{2}{3}}y=x^{\frac{2}{3}}
85x^{2}+y^{2}\le 4x^2+y^2\le 4
86y=\sin^{2}\left(x\right)y=\sin^2\left(x\right)
87\left(1,2\right)\left(1,2\right)
88\left[1,2,3\right]\left[1,2,3\right]
89a=\frac{-b\pm\sqrt{b^{2}-4ac}}{2a}a=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
90y=\left\{x<0:-x,x\right\}y=\left\{x<0:-x,x\right\}
91\sum_{n=1}^{5}n^2\sum_{n=1}^5n^2
92\pi r^{2}\pi r^2