mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
feat: support {equation}, {equation*}, and {split} (#2369)
* Support {equation}, {equation*}, and {split} * Update screenshots * Allow {split} at top level * Move equation column number check to to ParseArray * Add token to ParseError * Sharpen parameters passed to parseArray * Add token information * Update an {array} spec in screenshotter * Adjust {array} screenshotter spec * Make a non-strict error call when {array} argument specifies too few columns. * Move context checks to a helper function.
This commit is contained in:
@@ -2727,8 +2727,6 @@ describe("An aligned environment", function() {
|
||||
});
|
||||
|
||||
describe("AMS environments", function() {
|
||||
const nonStrictDisplay = new Settings({displayMode: true, strict: false});
|
||||
|
||||
it("should fail outside display mode", () => {
|
||||
expect`\begin{gather}a+b\\c+d\end{gather}`.not.toParse(nonstrictSettings);
|
||||
expect`\begin{gather*}a+b\\c+d\end{gather*}`.not.toParse(nonstrictSettings);
|
||||
@@ -2736,8 +2734,11 @@ describe("AMS environments", function() {
|
||||
expect`\begin{align*}a&=b+c\\d+e&=f\end{align*}`.not.toParse(nonstrictSettings);
|
||||
expect`\begin{alignat}{2}10&x+ &3&y = 2\\3&x+&13&y = 4\end{alignat}`.not.toParse(nonstrictSettings);
|
||||
expect`\begin{alignat*}{2}10&x+ &3&y = 2\\3&x+&13&y = 4\end{alignat*}`.not.toParse(nonstrictSettings);
|
||||
expect`\begin{equation}a=b+c\end{equation}`.not.toParse(nonstrictSettings);
|
||||
expect`\begin{split}a &=b+c\\&=e+f\end{split}`.not.toParse(nonstrictSettings);
|
||||
});
|
||||
|
||||
const nonStrictDisplay = new Settings({displayMode: true, strict: false});
|
||||
it("should build if in non-strict display mode", () => {
|
||||
expect`\begin{gather}a+b\\c+d\end{gather}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{gather*}a+b\\c+d\end{gather*}`.toBuild(nonStrictDisplay);
|
||||
@@ -2745,6 +2746,22 @@ describe("AMS environments", function() {
|
||||
expect`\begin{align*}a&=b+c\\d+e&=f\end{align*}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{alignat}{2}10&x+ &3&y = 2\\3&x+&13&y = 4\end{alignat}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{alignat*}{2}10&x+ &3&y = 2\\3&x+&13&y = 4\end{alignat*}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{equation}a=b+c\end{equation}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{equation}\begin{split}a &=b+c\\&=e+f\end{split}\end{equation}`.toBuild(nonStrictDisplay);
|
||||
expect`\begin{split}a &=b+c\\&=e+f\end{split}`.toBuild(nonStrictDisplay);
|
||||
});
|
||||
|
||||
it("{equation} should fail if argument contains two rows.", () => {
|
||||
expect`\begin{equation}a=\cr b+c\end{equation}`.not.toParse(nonStrictDisplay);
|
||||
});
|
||||
it("{equation} should fail if argument contains two columns.", () => {
|
||||
expect`\begin{equation}a &=b+c\end{equation}`.not.toBuild(nonStrictDisplay);
|
||||
});
|
||||
it("{split} should fail if argument contains three columns.", () => {
|
||||
expect`\begin{equation}\begin{split}a &=b &+c\\&=e &+f\end{split}\end{equation}`.not.toBuild(nonStrictDisplay);
|
||||
});
|
||||
it("{array} should fail if body contains more columns than specification.", () => {
|
||||
expect`\begin{array}{2}a & b & c\\d & e f\end{array}`.not.toBuild(nonStrictDisplay);
|
||||
});
|
||||
});
|
||||
|
||||
|
BIN
test/screenshotter/images/Equation-chrome.png
Normal file
BIN
test/screenshotter/images/Equation-chrome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/Equation-firefox.png
Normal file
BIN
test/screenshotter/images/Equation-firefox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@@ -15,7 +15,7 @@
|
||||
|
||||
Accents: \vec{A}\vec{x}\vec x^2\vec{x}_2^2\vec{A}^2\vec{xA}^2
|
||||
AccentsText: |
|
||||
\begin{array}{l}
|
||||
\begin{array}{lccccc}
|
||||
\text{\'\i} & \text{\.\i} & \text{\`\i} & \text{\"\i} & \text{\H\i} & \text{\r\i} \\
|
||||
\text{\'\j} & \text{\.\j} & \text{\`\j} & \text{\"\j} & \text{\H\j} & \text{\r\j} \\
|
||||
\text{\'a} & \text{\.a} & \text{\`a} & \text{\"a} & \text{\H{a}} & \text{\r{a}} \\
|
||||
@@ -129,6 +129,9 @@ Dots: |
|
||||
\cdots;\dots+\dots\int\dots,\dots \\
|
||||
\cdots{};\ldots+\ldots\int\ldots,\ldots
|
||||
\end{array}
|
||||
Equation:
|
||||
tex: \begin{equation}\begin{split}a& =b+c-d \\ & \quad +e-f \\ & =g+h \\ & =i \end{split}\end{equation}
|
||||
display: 1
|
||||
Exponents: a^{a^a_a}_{a^a_a}
|
||||
ExtensibleArrows: |
|
||||
\begin{array}{l}
|
||||
|
Reference in New Issue
Block a user