Socket
Socket
Sign inDemoInstall

mathpix-markdown-it

Package Overview
Dependencies
Maintainers
2
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathpix-markdown-it - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

LICENSE

1

lib/markdown/mdPluginText.js

@@ -377,2 +377,3 @@ "use strict";

return function (md) {
exports.resetCounter();
md.block.ruler.before("heading", "headingSection", headingSection);

@@ -379,0 +380,0 @@ md.block.ruler.before("paragraphDiv", "abstractBlock", abstractBlock);

551

lib/mathjax/serialized-ascii/handlers.js

@@ -6,50 +6,60 @@ "use strict";

var isFirstChild = function (node) {
return node.parent.childNodes[0] === node;
return node.parent && node.parent.childNodes[0] && node.parent.childNodes[0] === node;
};
var isLastChild = function (node) {
return node.parent.childNodes[node.parent.childNodes.length - 1] === node;
return node.parent && node.parent.childNodes && node.parent.childNodes[node.parent.childNodes.length - 1] === node;
};
var needFirstSpase = function (node) {
if (isFirstChild(node)) {
return false;
}
else {
var index = node.parent.childNodes.findIndex(function (item) { return item === node; });
var prev = node.parent.childNodes[index - 1];
if (prev.kind === 'mi' || prev.kind === 'mo') {
var text = prev.childNodes[0].text;
return regW.test(text[0]);
try {
if (isFirstChild(node)) {
return false;
}
else {
return false;
var index = node.parent.childNodes.findIndex(function (item) { return item === node; });
var prev = node.parent.childNodes[index - 1];
if (prev.kind === 'mi' || prev.kind === 'mo') {
var text = prev.childNodes[0] ? prev.childNodes[0].text : '';
return regW.test(text[0]);
}
else {
return false;
}
}
}
catch (e) {
return false;
}
};
var needLastSpase = function (node) {
var haveSpace = false;
if (node.parent.kind === "msubsup") {
return false;
}
if (isLastChild(node)) {
return false;
}
else {
var index = node.parent.childNodes.findIndex(function (item) { return item === node; });
var next = node.parent.childNodes[index + 1];
if (next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061' && !isLastChild(next)) {
next = node.parent.childNodes[index + 2];
haveSpace = true;
try {
if (node.parent.kind === "msubsup") {
return false;
}
if (next.kind === 'mi' || next.kind === 'mo') {
var text = next.childNodes[0].text;
if (next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061') {
return true;
}
var abs = exports.SymbolToAM(next.kind, text);
return regW.test(abs);
if (isLastChild(node)) {
return false;
}
else {
return haveSpace;
var index = node.parent.childNodes.findIndex(function (item) { return item === node; });
var next = node.parent.childNodes[index + 1];
if (next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061' && !isLastChild(next)) {
next = node.parent.childNodes[index + 2];
haveSpace = true;
}
if (next.kind === 'mi' || next.kind === 'mo') {
var text = next.childNodes[0] ? next.childNodes[0].text : '';
if (next.childNodes[0] && next.childNodes[0].kind === 'text' && next.childNodes[0].text === '\u2061') {
return true;
}
var abs = exports.SymbolToAM(next.kind, text);
return regW.test(abs);
}
else {
return haveSpace;
}
}
}
catch (e) {
return haveSpace;
}
};

@@ -140,6 +150,11 @@ exports.SymbolToAM = function (tag, output, atr, showStyle) {

var text = '';
node.childNodes.forEach(function (child) {
text += child.text;
});
return text;
try {
node.childNodes.forEach(function (child) {
text += child.text;
});
return text;
}
catch (e) {
return text;
}
};

@@ -155,16 +170,22 @@ var defHandle = function (node, serialize) {

var mml = '';
var atr = exports.getAttributes(node);
var isLeft = false;
var isRight = false;
var isBottom = false;
if (atr && atr.notation) {
isLeft = atr.notation.toString().indexOf('left') > -1;
isRight = atr.notation.toString().indexOf('right') > -1;
isBottom = atr.notation.toString().indexOf('bottom') > -1;
try {
var atr = exports.getAttributes(node);
var isLeft = false;
var isRight = false;
var isBottom = false;
if (atr && atr.notation) {
isLeft = atr.notation.toString().indexOf('left') > -1;
isRight = atr.notation.toString().indexOf('right') > -1;
isBottom = atr.notation.toString().indexOf('bottom') > -1;
}
mml += isLeft ? '[' : '';
mml += handlerApi.handleAll(node, serialize);
mml += isBottom ? ',[hline]' : '';
mml += isRight ? ']' : '';
return mml;
}
mml += isLeft ? '[' : '';
mml += handlerApi.handleAll(node, serialize);
mml += isBottom ? ',[hline]' : '';
mml += isRight ? ']' : '';
return mml;
catch (e) {
console.error('mml => menclose =>', e);
return mml;
}
};

@@ -175,9 +196,15 @@ };

var mml = '';
for (var i = 0; i < node.childNodes.length; i++) {
if (i > 0) {
mml += ',';
try {
for (var i = 0; i < node.childNodes.length; i++) {
if (i > 0) {
mml += ',';
}
mml += serialize.visitNode(node.childNodes[i], '');
}
mml += serialize.visitNode(node.childNodes[i], '');
return mml;
}
return mml;
catch (e) {
console.error('mml => mtable =>', e);
return mml;
}
};

@@ -188,11 +215,17 @@ };

var mml = '';
mml += node.parent.childNodes.length > 1 || serialize.options.extraBrackets ? '[' : '';
for (var i = 0; i < node.childNodes.length; i++) {
if (i > 0) {
mml += ',';
try {
mml += node.parent.childNodes.length > 1 || serialize.options.extraBrackets ? '[' : '';
for (var i = 0; i < node.childNodes.length; i++) {
if (i > 0) {
mml += ',';
}
mml += serialize.visitNode(node.childNodes[i], '');
}
mml += serialize.visitNode(node.childNodes[i], '');
mml += node.parent.childNodes.length > 1 || serialize.options.extraBrackets ? ']' : '';
return mml;
}
mml += node.parent.childNodes.length > 1 || serialize.options.extraBrackets ? ']' : '';
return mml;
catch (e) {
console.error('mml => mtr =>', e);
return mml;
}
};

@@ -203,6 +236,12 @@ };

var mml = '';
mml += '"';
mml += handlerApi.handleAll(node, serialize, mml);
mml += '"';
return mml;
try {
mml += '"';
mml += handlerApi.handleAll(node, serialize, mml);
mml += '"';
return mml;
}
catch (e) {
console.error('mml => mpadded =>', e);
return mml;
}
};

@@ -213,24 +252,30 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
if (secondChild.kind === 'mo') {
var t = serialize.visitNode(secondChild, '');
var asc = exports.FindSymbolToAM('mover', t, exports.getAttributes(secondChild));
if (asc) {
mml += ' ' + asc + '(';
mml += serialize.visitNode(firstChild, '').trim();
mml += ')';
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : '';
var secondChild = node.childNodes[1] ? node.childNodes[1] : '';
if (secondChild && secondChild.kind === 'mo') {
var t = serialize.visitNode(secondChild, '');
var asc = exports.FindSymbolToAM('mover', t, exports.getAttributes(secondChild));
if (asc) {
mml += ' ' + asc + '(';
mml += serialize.visitNode(firstChild, '').trim();
mml += ')';
}
else {
mml += serialize.visitNode(firstChild, '');
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
}
}
else {
mml += serialize.visitNode(firstChild, '');
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
mml += handlerApi.handleAll(node, serialize);
}
return mml;
}
else {
mml += handlerApi.handleAll(node, serialize);
catch (e) {
console.error('mml => mover =>', e);
return mml;
}
return mml;
};

@@ -241,24 +286,30 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
if (secondChild.kind === 'mo') {
var t = serialize.visitNode(secondChild, '');
var asc = exports.FindSymbolToAM(node.kind, t);
if (asc) {
mml += asc + '(';
mml += serialize.visitNode(firstChild, '');
mml += ')';
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
if (secondChild && secondChild.kind === 'mo') {
var t = serialize.visitNode(secondChild, '');
var asc = exports.FindSymbolToAM(node.kind, t);
if (asc) {
mml += asc + '(';
mml += serialize.visitNode(firstChild, '');
mml += ')';
}
else {
mml += handlerApi.handleAll(node, serialize);
}
}
else {
mml += handlerApi.handleAll(node, serialize);
mml += firstChild ? serialize.visitNode(firstChild, '') : '';
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += secondChild ? serialize.visitNode(secondChild, '') : '';
mml += serialize.options.extraBrackets ? ')' : '';
}
return mml;
}
else {
mml += serialize.visitNode(firstChild, '');
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
catch (e) {
console.error('mml => munder =>', e);
return mml;
}
return mml;
};

@@ -269,15 +320,21 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
var thirdChild = node.childNodes[2];
mml += serialize.visitNode(firstChild, '');
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(thirdChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
var thirdChild = node.childNodes[2] ? node.childNodes[2] : null;
mml += firstChild ? serialize.visitNode(firstChild, '') : null;
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += secondChild ? serialize.visitNode(secondChild, '') : null;
mml += serialize.options.extraBrackets ? ')' : '';
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += thirdChild ? serialize.visitNode(thirdChild, '') : null;
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
}
catch (e) {
console.error('mml => munderover =>', e);
return mml;
}
};

@@ -288,10 +345,16 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
mml += serialize.visitNode(firstChild, '');
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
mml += firstChild ? serialize.visitNode(firstChild, '') : '';
mml += '_';
mml += serialize.options.extraBrackets ? '(' : '';
mml += secondChild ? serialize.visitNode(secondChild, '') : '';
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
}
catch (e) {
console.error('mml => msub =>', e);
return mml;
}
};

@@ -302,10 +365,16 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
mml += serialize.visitNode(firstChild, '');
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += serialize.visitNode(secondChild, '');
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
mml += firstChild ? serialize.visitNode(firstChild, '') : '';
mml += '^';
mml += serialize.options.extraBrackets ? '(' : '';
mml += secondChild ? serialize.visitNode(secondChild, '') : '';
mml += serialize.options.extraBrackets ? ')' : '';
return mml;
}
catch (e) {
console.error('mml => msup =>', e);
return mml;
}
};

@@ -316,15 +385,21 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
var thirdChild = node.childNodes[2];
mml += serialize.visitNode(firstChild, '');
mml += '_';
mml += '(';
mml += serialize.visitNode(secondChild, '');
mml += ')';
mml += '^';
mml += '(';
mml += serialize.visitNode(thirdChild, '');
mml += ')';
return mml;
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
var thirdChild = node.childNodes[2] ? node.childNodes[2] : null;
mml += firstChild ? serialize.visitNode(firstChild, '') : '';
mml += '_';
mml += '(';
mml += secondChild ? serialize.visitNode(secondChild, '') : '';
mml += ')';
mml += '^';
mml += '(';
mml += thirdChild ? serialize.visitNode(thirdChild, '') : '';
mml += ')';
return mml;
}
catch (e) {
console.error('mml => msubsup =>', e);
return mml;
}
};

@@ -335,6 +410,12 @@ };

var mml = '';
mml += 'sqrt(';
mml += handlerApi.handleAll(node, serialize, mml);
mml += ')';
return mml;
try {
mml += 'sqrt(';
mml += handlerApi.handleAll(node, serialize, mml);
mml += ')';
return mml;
}
catch (e) {
console.error('mml => msqrt =>', e);
return mml;
}
};

@@ -345,8 +426,14 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
mml += 'root';
mml += '(' + serialize.visitNode(firstChild, '') + ')';
mml += '(' + serialize.visitNode(secondChild, '') + ')';
return mml;
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
mml += 'root';
mml += firstChild ? '(' + serialize.visitNode(firstChild, '') + ')' : '';
mml += secondChild ? '(' + serialize.visitNode(secondChild, '') + ')' : '';
return mml;
}
catch (e) {
console.error('mml => mroot =>', e);
return mml;
}
};

@@ -357,22 +444,28 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var secondChild = node.childNodes[1];
if ((firstChild.kind === "mrow" && firstChild.childNodes.length > 1) || serialize.options.extraBrackets) {
mml += '(';
mml += serialize.visitNode(firstChild, '');
mml += ')';
try {
var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
var secondChild = node.childNodes[1] ? node.childNodes[1] : null;
if ((firstChild && firstChild.kind === "mrow" && firstChild.childNodes.length > 1) || serialize.options.extraBrackets) {
mml += '(';
mml += serialize.visitNode(firstChild, '');
mml += ')';
}
else {
mml += serialize.visitNode(firstChild, '');
}
mml += '/';
if ((secondChild && secondChild.kind === "mrow" && secondChild.childNodes.length > 1) || serialize.options.extraBrackets) {
mml += '(';
mml += serialize.visitNode(secondChild, '');
mml += ')';
}
else {
mml += serialize.visitNode(secondChild, '');
}
return mml;
}
else {
mml += serialize.visitNode(firstChild, '');
catch (e) {
console.error('mml => mfrac =>', e);
return mml;
}
mml += '/';
if ((secondChild.kind === "mrow" && secondChild.childNodes.length > 1) || serialize.options.extraBrackets) {
mml += '(';
mml += serialize.visitNode(secondChild, '');
mml += ')';
}
else {
mml += serialize.visitNode(secondChild, '');
}
return mml;
};

@@ -383,16 +476,25 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var value = firstChild.text;
var asc = exports.FindSymbolToAM(node.kind, value);
if (asc) {
mml += asc;
try {
if (!node.childNodes || node.childNodes.length === 0) {
return mml;
}
var firstChild = node.childNodes[0];
var value = firstChild.text;
var asc = exports.FindSymbolToAM(node.kind, value);
if (asc) {
mml += asc;
return mml;
}
if (value[0] === '(') {
mml += value;
}
else {
mml += '"' + value + '"';
}
return mml;
}
if (value[0] === '(') {
mml += value;
catch (e) {
console.error('mml => mtext =>', e);
return mml;
}
else {
mml += '"' + value + '"';
}
return mml;
};

@@ -403,17 +505,26 @@ };

var mml = '';
var firstChild = node.childNodes[0];
var value = firstChild.text;
var atr = serialize.options.showStyle
? exports.getAttributes(node)
: null;
var abs = exports.SymbolToAM(node.kind, value, atr);
if (abs.length > 1 && regW.test(abs[0])) {
mml += needFirstSpase(node) ? ' ' : '';
mml += abs;
mml += needLastSpase(node) ? ' ' : '';
try {
if (!node.childNodes || node.childNodes.length === 0) {
return mml;
}
var firstChild = node.childNodes[0];
var value = firstChild.text;
var atr = serialize.options.showStyle
? exports.getAttributes(node)
: null;
var abs = exports.SymbolToAM(node.kind, value, atr);
if (abs && abs.length > 1 && regW.test(abs[0])) {
mml += needFirstSpase(node) ? ' ' : '';
mml += abs;
mml += needLastSpase(node) ? ' ' : '';
}
else {
mml += abs;
}
return mml;
}
else {
mml += abs;
catch (e) {
console.error('mml => mi =>', e);
return mml;
}
return mml;
};

@@ -424,18 +535,24 @@ };

var mml = '';
var value = getChilrenText(node);
var atr = exports.getAttributes(node);
if (atr && atr.hasOwnProperty('fence') && atr.fence) {
mml += node.texClass === 4 ? '{:' : '';
mml += node.texClass === 5 ? ':}' : '';
try {
var value = getChilrenText(node);
var atr = exports.getAttributes(node);
if (atr && atr.hasOwnProperty('fence') && atr.fence) {
mml += node.texClass === 4 ? '{:' : '';
mml += node.texClass === 5 ? ':}' : '';
}
var abs = exports.SymbolToAM(node.kind, value, atr, serialize.options.showStyle);
if (abs && abs.length > 1) {
mml += regW.test(abs[0]) && needFirstSpase(node) ? ' ' : '';
mml += abs;
mml += regW.test(abs[abs.length - 1]) && needLastSpase(node) ? ' ' : '';
}
else {
mml += abs;
}
return mml;
}
var abs = exports.SymbolToAM(node.kind, value, atr, serialize.options.showStyle);
if (abs.length > 1) {
mml += regW.test(abs[0]) && needFirstSpase(node) ? ' ' : '';
mml += abs;
mml += regW.test(abs[abs.length - 1]) && needLastSpase(node) ? ' ' : '';
catch (e) {
console.error('mml => mo =>', e);
return mml;
}
else {
mml += abs;
}
return mml;
};

@@ -446,13 +563,19 @@ };

var mml = '';
var atr = exports.getAttributes(node);
if (atr && atr.width === "2em") {
mml += 'qquad';
try {
var atr = exports.getAttributes(node);
if (atr && atr.width === "2em") {
mml += 'qquad';
return mml;
}
if (atr && atr.width === "1em") {
mml += 'quad';
return mml;
}
mml += handlerApi.handleAll(node, serialize, mml);
return mml;
}
if (atr && atr.width === "1em") {
mml += 'quad';
catch (e) {
console.error('mml => mspace =>', e);
return mml;
}
mml += handlerApi.handleAll(node, serialize, mml);
return mml;
};

@@ -459,0 +582,0 @@ };

@@ -24,96 +24,111 @@ "use strict";

SerializedAsciiVisitor.prototype.needsGrouping = function (element) {
if (element.parent
&& (element.parent.kind === 'math' || element.parent.kind === 'mstyle'
|| element.parent.kind === 'mtable' || element.parent.kind === 'mtr' || element.parent.kind === 'mtd' || element.parent.kind === 'menclose')) {
return false;
}
if (this.options.extraBrackets) {
if (element.parent.parent && (element.parent.parent.kind === 'msup' || element.parent.parent.kind === 'msub' || element.parent.parent.kind === 'msubsup'
|| element.parent.parent.kind === 'mover' || element.parent.parent.kind === 'munder' || element.parent.parent.kind === 'munderover')) {
try {
if (element.parent
&& (element.parent.kind === 'math' || element.parent.kind === 'mstyle'
|| element.parent.kind === 'mtable' || element.parent.kind === 'mtr' || element.parent.kind === 'mtd' || element.parent.kind === 'menclose')) {
return false;
}
}
if (element.parent.kind === 'TeXAtom' && element.parent.parent.kind === 'inferredMrow') {
return false;
}
if (element.childNodes && element.childNodes.length === 1) {
if (element.childNodes[0].childNodes && element.childNodes[0].childNodes.length === 1) {
if (this.options.extraBrackets) {
if (element.parent.parent && (element.parent.parent.kind === 'msup' || element.parent.parent.kind === 'msub' || element.parent.parent.kind === 'msubsup'
|| element.parent.parent.kind === 'mover' || element.parent.parent.kind === 'munder' || element.parent.parent.kind === 'munderover')) {
return false;
}
}
if (element.parent.kind === 'TeXAtom' && element.parent.parent.kind === 'inferredMrow') {
return false;
}
if (element.childNodes && element.childNodes.length === 1) {
if (element.childNodes[0].childNodes && element.childNodes[0].childNodes.length === 1) {
return false;
}
}
if (element.properties && element.properties.open === '(' && element.properties.close === ')') {
return false;
}
var firstChild = element.childNodes[0];
if (element.childNodes.length == 1 && firstChild.kind == 'mtext') {
return false;
}
return true;
}
if (element.properties && element.properties.open === '(' && element.properties.close === ')') {
catch (e) {
return false;
}
var firstChild = element.childNodes[0];
if (element.childNodes.length == 1 && firstChild.kind == 'mtext') {
return false;
}
return true;
};
SerializedAsciiVisitor.prototype.needsGroupingStyle = function (element) {
if (element.childNodes.length < 2) {
return null;
try {
if (element.childNodes.length < 2) {
return null;
}
var firstChild = element.childNodes[0];
var firstAtr = this.getAttributes(firstChild);
if (!firstAtr || !firstAtr.mathvariant || !firstAtr.hasOwnProperty('mathvariant')) {
return null;
}
for (var i = 1; i < element.childNodes.length; i++) {
var atr = this.getAttributes(element.childNodes[i]);
if (!atr || atr.mathvariant !== firstAtr.mathvariant) {
return null;
}
}
return firstAtr;
}
var firstChild = element.childNodes[0];
var firstAtr = this.getAttributes(firstChild);
if (!firstAtr || !firstAtr.mathvariant || !firstAtr.hasOwnProperty('mathvariant')) {
catch (e) {
return null;
}
for (var i = 1; i < element.childNodes.length; i++) {
var atr = this.getAttributes(element.childNodes[i]);
if (!atr || atr.mathvariant !== firstAtr.mathvariant) {
return null;
}
}
return firstAtr;
};
SerializedAsciiVisitor.prototype.visitInferredMrowNode = function (node, space) {
var mml = [];
var iclose = node.childNodes.findIndex(function (child) { return child.kind === 'menclose'; });
if (iclose > -1) {
var mclose = node.childNodes[iclose];
var atr = this.getAttributes(mclose);
var atrDef = this.getAttributesDefaults(mclose);
var longdiv = '';
if ((!atr.notation && atrDef.notation === "longdiv") || atr.notation.toString().indexOf("longdiv") !== -1) {
if (iclose === 0) {
longdiv += '(()/(';
longdiv += this.visitNode(mclose, '');
longdiv += '))';
}
else {
if (iclose - 1 > 0) {
for (var i = 0; i < iclose - 1; i++) {
longdiv += this.visitNode(node.childNodes[i], space);
}
try {
var iclose = node.childNodes.findIndex(function (child) { return child.kind === 'menclose'; });
if (iclose > -1) {
var mclose = node.childNodes[iclose];
var atr = this.getAttributes(mclose);
var atrDef = this.getAttributesDefaults(mclose);
var longdiv = '';
if ((!atr.notation && atrDef.notation === "longdiv") || atr.notation.toString().indexOf("longdiv") !== -1) {
if (iclose === 0) {
longdiv += '(()/(';
longdiv += this.visitNode(mclose, '');
longdiv += '))';
}
longdiv += '((';
var firstChild = node.childNodes[iclose - 1];
longdiv += this.visitNode(firstChild, '');
longdiv += ')/(';
longdiv += this.visitNode(mclose, '');
longdiv += '))';
if (iclose < node.childNodes.length - 1) {
for (var i = iclose + 1; i < node.childNodes.length; i++) {
longdiv += this.visitNode(node.childNodes[i], space);
else {
if (iclose - 1 > 0) {
for (var i = 0; i < iclose - 1; i++) {
longdiv += this.visitNode(node.childNodes[i], space);
}
}
longdiv += '((';
var firstChild = node.childNodes[iclose - 1];
longdiv += this.visitNode(firstChild, '');
longdiv += ')/(';
longdiv += this.visitNode(mclose, '');
longdiv += '))';
if (iclose < node.childNodes.length - 1) {
for (var i = iclose + 1; i < node.childNodes.length; i++) {
longdiv += this.visitNode(node.childNodes[i], space);
}
}
}
mml.push(longdiv);
return mml.join('');
}
mml.push(longdiv);
return mml.join('');
}
var addParens = this.needsGrouping(node);
var group = addParens ? this.needsGroupingStyle(node) : null;
if (addParens && !group) {
mml.push('(');
}
for (var _i = 0, _a = node.childNodes; _i < _a.length; _i++) {
var child = _a[_i];
mml.push(this.visitNode(child, space));
}
if (addParens && !group) {
mml.push(')');
}
return mml.join('');
}
var addParens = this.needsGrouping(node);
var group = addParens ? this.needsGroupingStyle(node) : null;
if (addParens && !group) {
mml.push('(');
catch (e) {
return '';
}
for (var _i = 0, _a = node.childNodes; _i < _a.length; _i++) {
var child = _a[_i];
mml.push(this.visitNode(child, space));
}
if (addParens && !group) {
mml.push(')');
}
return mml.join('');
};

@@ -136,13 +151,18 @@ SerializedAsciiVisitor.prototype.visitTeXAtomNode = function (node, space) {

var mml = '';
if (node.kind === 'mover' && node.childNodes.length > 1 && node.childNodes[0].kind === 'TeXAtom' && node.childNodes[1].kind === 'TeXAtom') {
var firstChild = node.childNodes[0];
firstChild.properties.needBrackets = true;
mml += handleCh(firstChild, this);
mml += '^';
mml += '(' + handleCh(node.childNodes[1], this) + ')';
try {
if (node.kind === 'mover' && node.childNodes.length > 1 && node.childNodes[0].kind === 'TeXAtom' && node.childNodes[1].kind === 'TeXAtom') {
var firstChild = node.childNodes[0];
firstChild.properties.needBrackets = true;
mml += handleCh(firstChild, this);
mml += '^';
mml += '(' + handleCh(node.childNodes[1], this) + ')';
}
else {
mml += handleCh(node, this);
}
return mml;
}
else {
mml += handleCh(node, this);
catch (e) {
return mml;
}
return mml;
};

@@ -149,0 +169,0 @@ SerializedAsciiVisitor.prototype.getAttributes = function (node) {

{
"name": "mathpix-markdown-it",
"version": "1.0.4",
"version": "1.0.5",
"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)",

@@ -31,3 +31,3 @@ "keywords": [

},
"license": "ISC",
"license": "MIT",
"author": "Mathpix",

@@ -34,0 +34,0 @@ "main": "lib/index.js",

@@ -5,4 +5,4 @@ # mathpix-markdown-it

[![Build Status](https://img.shields.io/circleci/build/gh/Mathpix/mathpix-markdown-it/master.svg?style=flat)](https://circleci.com/gh/Mathpix/mathpix-markdown-it/tree/master)
[![GitHub](https://img.shields.io/github/license/mathpix/mathpix-markdown-it)](https://github.com/Mathpix/mathpix-markdown-it/blob/master/LICENSE)
# What is Mathpix Markdown?

@@ -9,0 +9,0 @@

@@ -83,2 +83,15 @@ //Require the dev-dependencies

});
describe('Testing More equation:', () => {
const tests = require('./_data/_ascii/_asciiMore');
tests.forEach(function(test) {
it('Latex =>' + test.latex, function(done) {
const data = MathJax.TexConvert(test.latex, options);
console.log(' LATEX =>', test.latex);
console.log(' ASCIIMATH =>', test.ascii);
data.should.have.property('asciimath', test.ascii);
done();
});
});
});
// {

@@ -85,0 +98,0 @@ // latex: `\\left.\\begin{array}{l}{\\text{foo}} \\\\ { \\theta + C }\\end{array} \\right.`,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc