Skip to content

Commit

Permalink
Merge pull request #6 from asnunes/fix-command-spacing
Browse files Browse the repository at this point in the history
Fix command spacing
  • Loading branch information
asnunes authored Apr 11, 2021
2 parents dc847d7 + 27d442c commit 6b02fc8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 14.15.3
nodejs 14.16.1
8 changes: 8 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ describe('#convert', () => {

expect(result).toMatch('b');
});

it('appends space between command and next tag', () => {
const mathml = mathmlStrings.moWithCharOperatorAndMi;

const result = MathMLToLaTeX.convert(mathml);

expect(result).toMatch('a \\Rightarrow b');
});
});
});

Expand Down
12 changes: 12 additions & 0 deletions __tests__/mocks/mathmlStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ export const moWithCharOperator = `
</root>
`;

export const moWithCharOperatorAndMi = `
<root>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mi>a</mi>
<mo>&#x21D2;</mo>
<mi>b</mi>
</mstyle>
</math>
</root>
`;

export const mrowWithMnAndMo = `
<root>
<math>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mathml-to-latex",
"version": "1.0.1",
"version": "1.1.0",
"description": "A JavaScript tool to convert mathml string to LaTeX string",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export { MUnderover } from './munderover';
export { MTable } from './mtable';
export { MTr } from './mtr';
export { GenericSpacingWrapper } from './generic-spacing-wrapper';
export { GenericNoSpacingWrapper } from './generic-no-spacing-wrapper';
export { GenericUnderOver } from './generic-under-over';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class MathMLElementToLatexConverterAdapter {

toLatexConverter(): ToLaTeXConverter {
const { name } = this._mathMLElement;
const Converter = fromMathMLElementToLatexConverter[name] || ToLatexConverters.GenericNoSpacingWrapper;
const Converter = fromMathMLElementToLatexConverter[name] || ToLatexConverters.GenericSpacingWrapper;

return new Converter(this._mathMLElement);
}
Expand Down

0 comments on commit 6b02fc8

Please sign in to comment.