mathpix-markdown-it
Version:
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)
54 lines • 2.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckParseError = exports.ClearParseErrorList = exports.ClearParseError = exports.pushParseErrorList = exports.pushError = exports.ParseError = exports.ParseErrorList = void 0;
var mathpix_markdown_model_1 = require("../../mathpix-markdown-model");
exports.ParseErrorList = [];
exports.ParseError = [];
var pushError = function (messages) {
exports.ParseError.push(messages);
};
exports.pushError = pushError;
var pushParseErrorList = function (messages, ln) {
exports.ParseErrorList[ln] = messages;
};
exports.pushParseErrorList = pushParseErrorList;
var ClearParseError = function () {
exports.ParseError = [];
};
exports.ClearParseError = ClearParseError;
var ClearParseErrorList = function () {
exports.ParseErrorList = [];
};
exports.ClearParseErrorList = ClearParseErrorList;
var StatePushDivError = function (state, startLine, nextLine, content, ParseError, title) {
var token;
state.line = nextLine;
token = state.push('paragraph_open', 'div', 1);
if (state.md.options.parserErrors === mathpix_markdown_model_1.ParserErrors.show) {
token.attrs = [['class', 'math-error ']];
}
if (state.md.options.parserErrors === mathpix_markdown_model_1.ParserErrors.hide) {
token.attrSet('style', 'display: none;');
}
token.map = [startLine, state.line];
token = state.push('inline', '', 0);
token.children = [];
if (state.md.options.parserErrors === mathpix_markdown_model_1.ParserErrors.show) {
token.content = title + ParseError.concat('\n');
}
token = state.push('text', '', 0);
token.children = [];
token.content = content;
state.push('paragraph_close', 'div', -1);
(0, exports.ClearParseError)();
};
var CheckParseError = function (state, startLine, nextLine, content) {
if (exports.ParseError && exports.ParseError.length > 0) {
StatePushDivError(state, startLine, nextLine, content, exports.ParseError, 'Tabular parse error: ');
(0, exports.pushParseErrorList)(exports.ParseError, startLine);
return true;
}
return false;
};
exports.CheckParseError = CheckParseError;
//# sourceMappingURL=parse-error.js.map