mathpix-markdown-it
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -35,3 +35,3 @@ "use strict"; | ||
? el.querySelectorAll('.math-inline, .math-block, .table_tabular, .inline-tabular') | ||
: el.querySelectorAll('div > .math-inline, div > .math-block, div > .table_tabular, div > .inline-tabular'); | ||
: el.querySelectorAll('div > .math-inline, div > .math-block, .table_tabular, div > .inline-tabular'); | ||
if (!math_el) | ||
@@ -38,0 +38,0 @@ return null; |
{ | ||
"name": "mathpix-markdown-it", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Mathpix-markdown-it is an open source implementation of the mathpix-markdown spec written in Typescript. It relies on the following open source libraries: MathJax v3 (to render math with SVGs), markdown-it (for standard Markdown parsing)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -172,3 +172,3 @@ # mathpix-markdown-it | ||
}; | ||
const html = MM.markdownToHTML(`$x^x$`, options); | ||
const html = MathpixMarkdownModel.markdownToHTML(`$x^x$`, options); | ||
``` | ||
@@ -245,4 +245,4 @@ | ||
}; | ||
const html = MM.markdownToHTML(`$x^x$`, options); | ||
const parsed = MM.parseMarkdownByHTML(html, false); | ||
const html = MathpixMarkdownModel.markdownToHTML(`$x^x$`, options); | ||
const parsed = MathpixMarkdownModel.parseMarkdownByHTML(html, false); | ||
``` | ||
@@ -252,6 +252,9 @@ | ||
```html | ||
<span class="math-block"> | ||
<asciimath style="display: none">...</asciimath> | ||
<mjx-comtainer class="MathJax" jax="SVG">..</mjx-comtainer> | ||
</span> | ||
<div> | ||
<span class="math-inline"> | ||
<asciimath style="display: none;">x^(x)</asciimath> | ||
<mjx-comtainer class="MathJax" jax="SVG"><svg>...</svg></mjx-comtainer> | ||
</span> | ||
</div> | ||
``` | ||
@@ -278,12 +281,15 @@ | ||
include_table_html: false, | ||
include_tsv: true, | ||
} | ||
}; | ||
const html = MM.markdownToHTML(`\begin{tabular}{ c c } 1 & 2\\ 3 & 4\\ \end{tabular}`, options); | ||
const parsed = MM.parseMarkdownByHTML(html, false); | ||
const html = MathpixMarkdownModel.markdownToHTML(`\\begin{tabular}{ c c } 1 & 2\\\\ 3 & 4\\\\ \\end{tabular}`, options); | ||
const parsed = MathpixMarkdownModel.parseMarkdownByHTML(html, false); | ||
``` | ||
```html | ||
<div class="table_ tabular"> | ||
<tsv style="display: none">...</tsv> | ||
<div class="table_tabular " style="text-align: center"> | ||
<tsv style="display: none">1 2 | ||
3 4</tsv> | ||
</div> | ||
``` | ||
@@ -294,6 +300,6 @@ | ||
[ | ||
{ | ||
"type": "tsv", | ||
"value": "<tsv>...</tsv>" | ||
} | ||
{ | ||
type: 'tsv', | ||
value: '1\t2\n3\t4' | ||
} | ||
] | ||
@@ -325,4 +331,4 @@ ``` | ||
}; | ||
const html = MM.markdownToHTML(latex, options); | ||
const parsed = MM.parseMarkdownByHTML(html); | ||
const html = MathpixMarkdownModel.markdownToHTML(latex, options); | ||
const parsed = MathpixMarkdownModel.parseMarkdownByHTML(html); | ||
``` | ||
@@ -374,4 +380,4 @@ | ||
}; | ||
const html = MM.markdownToHTML(latex, options); | ||
const parsed = MM.parseMarkdownByHTML(html, false); | ||
const html = MathpixMarkdownModel.markdownToHTML(latex, options); | ||
const parsed = MathpixMarkdownModel.parseMarkdownByHTML(html, false); | ||
``` | ||
@@ -378,0 +384,0 @@ |
@@ -29,32 +29,32 @@ let chai = require('chai'); | ||
describe('Check parseMarkdownByHTML:', () => { | ||
const tests = require('./_data/_parseMarkdownByHTML/_data'); | ||
tests.forEach(function(test) { | ||
const html = MM.render(test.latex_input, options); | ||
const data = MM.parseMarkdownByHTML(html, false); | ||
describe('input_latex => ' + test.latex_input, () => { | ||
it('Should be length = 4', (done) => { | ||
data.should.have.length(4); | ||
done(); | ||
}); | ||
it('Should be return mathml =>', function(done) { | ||
data[0].should.have.property('type', 'mathml'); | ||
data[0].should.have.property('value', test.mathml); | ||
done(); | ||
}); | ||
it('Should be return asciimath =>', function(done) { | ||
data[1].should.have.property('type', 'asciimath'); | ||
data[1].should.have.property('value', test.asciimath); | ||
done(); | ||
}); | ||
it('Should be return latex =>', function(done) { | ||
data[2].should.have.property('type', 'latex'); | ||
data[2].should.have.property('value', test.latex); | ||
done(); | ||
}); | ||
it('Should be return svg =>', function(done) { | ||
data[3].should.have.property('type', 'svg'); | ||
const doc = JSDOM.fragment(data[3].value); | ||
doc.firstChild.tagName.should.equal('svg'); | ||
done(); | ||
}); | ||
const tests = require('./_data/_parseMarkdownByHTML/_data'); | ||
tests.forEach(function(test) { | ||
const html = MM.render(test.latex_input, options); | ||
const data = MM.parseMarkdownByHTML(html, false); | ||
describe('input_latex => ' + test.latex_input, () => { | ||
it('Should be length = 4', (done) => { | ||
data.should.have.length(4); | ||
done(); | ||
}); | ||
it('Should be return mathml =>', function(done) { | ||
data[0].should.have.property('type', 'mathml'); | ||
data[0].should.have.property('value', test.mathml); | ||
done(); | ||
}); | ||
it('Should be return asciimath =>', function(done) { | ||
data[1].should.have.property('type', 'asciimath'); | ||
data[1].should.have.property('value', test.asciimath); | ||
done(); | ||
}); | ||
it('Should be return latex =>', function(done) { | ||
data[2].should.have.property('type', 'latex'); | ||
data[2].should.have.property('value', test.latex); | ||
done(); | ||
}); | ||
it('Should be return svg =>', function(done) { | ||
data[3].should.have.property('type', 'svg'); | ||
const doc = JSDOM.fragment(data[3].value); | ||
doc.firstChild.tagName.should.equal('svg'); | ||
done(); | ||
}); | ||
}); | ||
@@ -82,1 +82,37 @@ }); | ||
}); | ||
describe('Test from example:', () => { | ||
const latex = String.raw`\begin{tabular}{ l c r } | ||
1 & {$x^1$} & 3 \\ | ||
4 & {$y^1$} & 6 \\ | ||
7 & {$z^1$} & 9 \\ | ||
\end{tabular}`; | ||
const options = { | ||
outMath: { | ||
include_asciimath: true, | ||
include_mathml: true, | ||
include_latex: true, | ||
include_svg: true, | ||
include_tsv: true, | ||
include_table_html: true | ||
} | ||
}; | ||
const html = MM.markdownToHTML(latex, options); | ||
const parsed = MM.parseMarkdownByHTML(html, false); | ||
describe('input_latex => ' , () => { | ||
it('Should be parser.length = 2', function(done) { | ||
parsed.should.have.length(2); | ||
done(); | ||
}); | ||
it('Should be have type: "html"', function(done) { | ||
parsed[0].should.have.property('type', 'html'); | ||
done(); | ||
}); | ||
it('Should be have type: "tsv"', function(done) { | ||
parsed[1].should.have.property('type', 'tsv'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4612849
10306
584