Merge pull request #6 from asnunes/fix-command-spacing
Fix command spacing
This commit is contained in:
commit
6b02fc8cac
@ -1 +1 @@
|
||||
nodejs 14.15.3
|
||||
nodejs 14.16.1
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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>⇒</mo>
|
||||
<mi>b</mi>
|
||||
</mstyle>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
export const mrowWithMnAndMo = `
|
||||
<root>
|
||||
<math>
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mathml-to-latex",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -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",
|
||||
|
@ -1,18 +0,0 @@
|
||||
import { ToLaTeXConverter } from '../../../../domain/usecases/to-latex-converter';
|
||||
import { MathMLElement } from '../../../protocols/mathml-element';
|
||||
import { mathMLElementToLaTeXConverter } from '../../../helpers';
|
||||
|
||||
export class GenericNoSpacingWrapper implements ToLaTeXConverter {
|
||||
private readonly _mathmlElement: MathMLElement;
|
||||
|
||||
constructor(mathElement: MathMLElement) {
|
||||
this._mathmlElement = mathElement;
|
||||
}
|
||||
|
||||
convert(): string {
|
||||
return this._mathmlElement.children
|
||||
.map((child) => mathMLElementToLaTeXConverter(child))
|
||||
.map((converter) => converter.convert())
|
||||
.join('');
|
||||
}
|
||||
}
|
@ -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';
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user