commit
6799980ca2
25
.github/workflows/publish.yml
vendored
Normal file
25
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Publish
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Dependencies installation
|
||||
run: npm install
|
||||
- name: Test run
|
||||
run: npm test
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Publish
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
access: public
|
13
.github/workflows/test.yml
vendored
Normal file
13
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: Test
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build test compose
|
||||
run: |
|
||||
make test-build
|
||||
make test
|
@ -13,3 +13,7 @@ tsconfig.json
|
||||
.prettierrc.js
|
||||
.tool-versions
|
||||
.vscode
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
.github
|
||||
makefile
|
||||
|
6
Dockerfile.test
Normal file
6
Dockerfile.test
Normal file
@ -0,0 +1,6 @@
|
||||
FROM node:14.17
|
||||
WORKDIR /usr/src/mathml-to-latex
|
||||
RUN npm -g i npm
|
||||
COPY ./package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
@ -11,6 +11,9 @@ import {
|
||||
mfencedWithSeparatorAttribute,
|
||||
mfencedWithBrokenAttributeCase1,
|
||||
mfencedWithBrokenAttributeCase2,
|
||||
mfencedWithBrokenAttributeCase4,
|
||||
mfencedWithBrokenAttributeCase3,
|
||||
mfencedWithBrokenAttributeCase5,
|
||||
} from '../../mocks/mathmlStrings';
|
||||
|
||||
describe('#convert', () => {
|
||||
@ -130,6 +133,58 @@ describe('#convert', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('given math with two broken mfenced', () => {
|
||||
test('add attributes to children related with name mfenced', () => {
|
||||
const mathmlString = mfencedWithBrokenAttributeCase3;
|
||||
|
||||
const result = makeSut().convert(mathmlString);
|
||||
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toMatchObject({
|
||||
name: 'math',
|
||||
value: '',
|
||||
attributes: {},
|
||||
children: [
|
||||
{
|
||||
name: 'mfenced',
|
||||
value: '',
|
||||
attributes: { open: '{' },
|
||||
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
|
||||
},
|
||||
{
|
||||
name: 'mfenced',
|
||||
value: '',
|
||||
attributes: { open: '{' },
|
||||
children: [{ name: 'mn', value: '5', attributes: {}, children: [] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('given math with two broken arguments', () => {
|
||||
test('ignore broken args', () => {
|
||||
const mathmlString = mfencedWithBrokenAttributeCase5;
|
||||
|
||||
const result = makeSut().convert(mathmlString);
|
||||
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toMatchObject({
|
||||
name: 'math',
|
||||
value: '',
|
||||
attributes: {},
|
||||
children: [
|
||||
{
|
||||
name: 'mfenced',
|
||||
value: '',
|
||||
attributes: {},
|
||||
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('given math string with mfenced with single content, open attr settled as { and close attribute with = only', () => {
|
||||
test('add attributes to children related with name mfenced', () => {
|
||||
const mathmlString = mfencedWithBrokenAttributeCase2;
|
||||
@ -152,4 +207,33 @@ describe('#convert', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('given math with two broken mfenced', () => {
|
||||
test('add attributes to children related with name mfenced', () => {
|
||||
const mathmlString = mfencedWithBrokenAttributeCase4;
|
||||
|
||||
const result = makeSut().convert(mathmlString);
|
||||
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toMatchObject({
|
||||
name: 'math',
|
||||
value: '',
|
||||
attributes: {},
|
||||
children: [
|
||||
{
|
||||
name: 'mfenced',
|
||||
value: '',
|
||||
attributes: { open: '{' },
|
||||
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
|
||||
},
|
||||
{
|
||||
name: 'mfenced',
|
||||
value: '',
|
||||
attributes: { open: '{' },
|
||||
children: [{ name: 'mn', value: '5', attributes: {}, children: [] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -46,6 +46,42 @@ export const mfencedWithBrokenAttributeCase2 = `
|
||||
</root>
|
||||
`;
|
||||
|
||||
export const mfencedWithBrokenAttributeCase3 = `
|
||||
<root>
|
||||
<math>
|
||||
<mfenced open='{' close >
|
||||
<mn>3</mn>
|
||||
</mfenced>
|
||||
<mfenced open='{' close >
|
||||
<mn>5</mn>
|
||||
</mfenced>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
export const mfencedWithBrokenAttributeCase4 = `
|
||||
<root>
|
||||
<math>
|
||||
<mfenced open='{' close= >
|
||||
<mn>3</mn>
|
||||
</mfenced>
|
||||
<mfenced open='{' close= >
|
||||
<mn>5</mn>
|
||||
</mfenced>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
export const mfencedWithBrokenAttributeCase5 = `
|
||||
<root>
|
||||
<math>
|
||||
<mfenced open='' close= >
|
||||
<mn>3</mn>
|
||||
</mfenced>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
export const mrootWithMi = '<root><math><mi>a</mi></math></root>';
|
||||
|
||||
export const mathWithMi = '<math><mi>b</mi></math>';
|
||||
|
15
docker-compose.test.yml
Normal file
15
docker-compose.test.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
mathml-to-latex-test:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.test
|
||||
container_name: mathml-to-latex-test
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
max-size: '10m'
|
||||
max-file: '5'
|
||||
working_dir: /usr/src/mathml-to-latex
|
||||
command: |
|
||||
npm run test
|
14
makefile
Normal file
14
makefile
Normal file
@ -0,0 +1,14 @@
|
||||
# TEST
|
||||
test_compose = docker-compose -f docker-compose.test.yml
|
||||
|
||||
.PRONY: test-build
|
||||
test-build:
|
||||
$(test_compose) build
|
||||
|
||||
.PRONY: test
|
||||
test:
|
||||
make test-build && $(test_compose) run mathml-to-latex-test && make test-down
|
||||
|
||||
.PRONY: test-down
|
||||
test-down:
|
||||
$(test_compose) down
|
7597
package-lock.json
generated
7597
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mathml-to-latex",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "A JavaScript tool to convert mathml string to LaTeX string",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@ -8,7 +8,7 @@
|
||||
"build": "rm -rf ./dist && tsc",
|
||||
"watch": "tsc -w",
|
||||
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
|
||||
"test": "jest --passWithNoTests --silent --noStackTrace --runInBand",
|
||||
"test": "jest --passWithNoTests --noStackTrace --runInBand",
|
||||
"test:verbose": "jest --passWithNoTests --runInBand",
|
||||
"test:watch": "npm run test -- --watch"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user