test: add mfenced and mtable as pmatrix
This commit is contained in:
parent
feef2d20a9
commit
01445dbe93
@ -327,33 +327,66 @@ describe('#convert', () => {
|
||||
|
||||
describe('when mfenced represents a matrix', () => {
|
||||
describe('given math string with mtable, mtr and mtd tag', () => {
|
||||
it('returns a matrix representation in latex', () => {
|
||||
const mathml = `
|
||||
<root>
|
||||
<math xmlns = "http://www.w3.org/1998/Math/MathML">
|
||||
<mrow>
|
||||
<mi>A</mi>
|
||||
<mo>=</mo>
|
||||
<mfenced open = "[" close="]">
|
||||
<mtable>
|
||||
<mtr>
|
||||
<mtd><mi>x</mi></mtd>
|
||||
<mtd><mi>y</mi></mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd><mi>z</mi></mtd>
|
||||
<mtd><mi>w</mi></mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
</mfenced>
|
||||
</mrow>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
describe('with open attribute as [', () => {
|
||||
it('returns a bmatrix representation in latex', () => {
|
||||
const mathml = `
|
||||
<root>
|
||||
<math xmlns = "http://www.w3.org/1998/Math/MathML">
|
||||
<mrow>
|
||||
<mi>A</mi>
|
||||
<mo>=</mo>
|
||||
<mfenced open = "[" close="]">
|
||||
<mtable>
|
||||
<mtr>
|
||||
<mtd><mi>x</mi></mtd>
|
||||
<mtd><mi>y</mi></mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd><mi>z</mi></mtd>
|
||||
<mtd><mi>w</mi></mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
</mfenced>
|
||||
</mrow>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
const result = MathMLToLaTeX.convert(mathml);
|
||||
const result = MathMLToLaTeX.convert(mathml);
|
||||
|
||||
expect(result).toBe('A = \\begin{bmatrix}\n x & y \\\\\n z & w \n\\end{bmatrix}'.replace(/\n/g, ''));
|
||||
expect(result).toBe('A = \\begin{bmatrix}\n x & y \\\\\n z & w \n\\end{bmatrix}'.replace(/\n/g, ''));
|
||||
});
|
||||
});
|
||||
|
||||
describe('with open attribute as [', () => {
|
||||
it('returns a bmatrix representation in latex', () => {
|
||||
const mathml = `
|
||||
<root>
|
||||
<math xmlns = "http://www.w3.org/1998/Math/MathML">
|
||||
<mrow>
|
||||
<mi>A</mi>
|
||||
<mo>=</mo>
|
||||
<mfenced open = "(" close=")">
|
||||
<mtable>
|
||||
<mtr>
|
||||
<mtd><mi>x</mi></mtd>
|
||||
<mtd><mi>y</mi></mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd><mi>z</mi></mtd>
|
||||
<mtd><mi>w</mi></mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
</mfenced>
|
||||
</mrow>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
const result = MathMLToLaTeX.convert(mathml);
|
||||
|
||||
expect(result).toBe('A = \\begin{pmatrix}\n x & y \\\\\n z & w \n\\end{pmatrix}'.replace(/\n/g, ''));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user