mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-15 06:52:23 +00:00
* 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>
2.7 KiB
2.7 KiB
| 1 | # input (MathLive-style LaTeX) | to_latex(from_linear(input)) |
|---|---|---|
| 2 | x^2 | x^2 |
| 3 | x^{2} | x^2 |
| 4 | x^{2+1} | x^{2+1} |
| 5 | x^{n^{2}} | x^{n^2} |
| 6 | x^2+3x-2 | x^2+3x-2 |
| 7 | 2x | 2x |
| 8 | 3x^2+2x-1 | 3x^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| |
| 32 | 2\pi x | 2\pi x |
| 33 | \sin(\pi x) | \sin\left(\pi x\right) |
| 34 | \theta | \theta |
| 35 | 1+\cos\theta | 1+\cos\left(\theta\right) |
| 36 | \infty | \infty |
| 37 | \mathrm{e}^{x} | \mathrm{e}^x |
| 38 | x_1+x_{12} | x_1+x_{12} |
| 39 | 2\cdot3 | 2\cdot3 |
| 40 | 2\times3 | 2\times3 |
| 41 | 4\div2 | 4\div2 |
| 42 | x\pm1 | x\pm1 |
| 43 | (x+1)(x-1) | \left(x+1\right)\left(x-1\right) |
| 44 | (x+1)2 | \left(x+1\right)2 |
| 45 | 2(x+1) | 2\left(x+1\right) |
| 46 | x^2+y^2-1 | x^2+y^2-1 |
| 47 | x--1 | x--1 |
| 48 | x++1 | x++1 |
| 49 | 3\sqrt{x} | 3\sqrt{x} |
| 50 | e^{-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) |
| 54 | 2\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} |
| 57 | a b | a b |
| 58 | \frac{1}{2}x | \frac{1}{2}x |
| 59 | x^{\frac{1}{2}} | x^{\frac{1}{2}} |
| 60 | \sin\theta | \sin\left(\theta\right) |
| 61 | 10x | 10x |
| 62 | 2.5x | 2.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) |
| 69 | x^{2}_{3} | x_3^2 |
| 70 | x^2+y^2=25 | x^2+y^2=25 |
| 71 | y=\frac{x^2-1}{x+1} | y=\frac{x^2-1}{x+1} |
| 72 | y=\sqrt{4-x^2} | y=\sqrt{4-x^2} |
| 73 | r=1+\cos\theta | r=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 |
| 75 | y=\left|x-3\right|+2 | y=\left|x-3\right|+2 |
| 76 | y=\sin\left(2x\right)\cos\left(x\right) | y=\sin\left(2x\right)\cos\left(x\right) |
| 77 | y=\frac{1}{2}x+\frac{3}{4} | y=\frac{1}{2}x+\frac{3}{4} |
| 78 | y=e^{x} | y=e^x |
| 79 | y=\ln\left(x+1\right) | y=\ln\left(x+1\right) |
| 80 | y=\sqrt[3]{x^2} | y=\sqrt[3]{x^2} |
| 81 | f\left(x\right)=ax^2+bx+c | f\left(x\right)=ax^2+bx+c |
| 82 | \frac{d}{dx}x^2 | \frac{d}{dx}x^2 |
| 83 | y=2^{x} | y=2^x |
| 84 | y=x^{\frac{2}{3}} | y=x^{\frac{2}{3}} |
| 85 | x^{2}+y^{2}\le 4 | x^2+y^2\le 4 |
| 86 | y=\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] |
| 89 | a=\frac{-b\pm\sqrt{b^{2}-4ac}}{2a} | a=\frac{-b\pm\sqrt{b^2-4ac}}{2a} |
| 90 | y=\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 |