Skip to content

Commit

Permalink
Merge pull request #23 from asnunes/feat/ms-word
Browse files Browse the repository at this point in the history
Feat/ms word
  • Loading branch information
asnunes authored Apr 15, 2024
2 parents 53bdbb7 + 4fc7cf5 commit ef73eac
Show file tree
Hide file tree
Showing 9 changed files with 1,923 additions and 2,692 deletions.
5 changes: 0 additions & 5 deletions .huskyrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.17.0
nodejs 20.12.2
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"workbench.editor.enablePreview": false
}
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.17
FROM node:20.12.2
WORKDIR /usr/src/mathml-to-latex
RUN npm -g i npm
COPY ./package*.json ./
Expand Down
8 changes: 8 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,4 +1159,12 @@ describe('#convert', () => {
});
}
});

it('should remove ms word prefixes and convert tags as expected', () => {
const result = MathMLToLaTeX.convert(mathmlStrings.msWordInput);

expect(result).toBe(
'V_{i} \\frac{\\Delta C_{A , i}^{t}}{\\Delta t} = \\sum_{j = k}^{N} G_{i , j}^{D} \\left(C_{A , j} - C_{A , i}\\right)',
);
});
});
3 changes: 3 additions & 0 deletions __tests__/mocks/mathmlStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,9 @@ type InputExpectedPair = {
op: 'mi' | 'mo' | 'mn';
};

export const msWordInput =
'<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"><mml:msub><mml:mrow><mml:mi>V</mml:mi></mml:mrow><mml:mrow><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mfrac><mml:mrow><mml:mi mathvariant="normal">Δ</mml:mi><mml:msubsup><mml:mrow><mml:mi>C</mml:mi></mml:mrow><mml:mrow><mml:mi>A</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi></mml:mrow><mml:mrow><mml:mi>t</mml:mi></mml:mrow></mml:msubsup></mml:mrow><mml:mrow><mml:mi mathvariant="normal">Δ</mml:mi><mml:mi>t</mml:mi></mml:mrow></mml:mfrac><mml:mo>=</mml:mo><mml:mrow><mml:munderover><mml:mo stretchy="false">∑</mml:mo><mml:mrow><mml:mi>j</mml:mi><mml:mo>=</mml:mo><mml:mi>k</mml:mi></mml:mrow><mml:mrow><mml:mi>N</mml:mi></mml:mrow></mml:munderover><mml:mrow><mml:msubsup><mml:mrow><mml:mi>G</mml:mi></mml:mrow><mml:mrow><mml:mi>i</mml:mi><mml:mo>,</mml:mo><mml:mi>j</mml:mi></mml:mrow><mml:mrow><mml:mi>D</mml:mi></mml:mrow></mml:msubsup><mml:mfenced separators="|"><mml:mrow><mml:msub><mml:mrow><mml:mi>C</mml:mi></mml:mrow><mml:mrow><mml:mi>A</mml:mi><mml:mo>,</mml:mo><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo>-</mml:mo><mml:msub><mml:mrow><mml:mi>C</mml:mi></mml:mrow><mml:mrow><mml:mi>A</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mfenced></mml:mrow></mml:mrow></mml:math>';

export const inputExpectedPairs = [
{
input: 'Ω',
Expand Down
Loading

0 comments on commit ef73eac

Please sign in to comment.