Socket
Socket
Sign inDemoInstall

mathpix-markdown-it

Package Overview
Dependencies
Maintainers
3
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.2.5 to 1.2.6

5

lib/components/mathpix-markdown/index.js

@@ -12,3 +12,3 @@ "use strict";

MathpixMarkdown.prototype.render = function () {
var _a = this.props, text = _a.text, _b = _a.alignMathBlock, alignMathBlock = _b === void 0 ? 'center' : _b, _c = _a.display, display = _c === void 0 ? 'block' : _c, _d = _a.isCheckFormula, isCheckFormula = _d === void 0 ? false : _d, _e = _a.showTimeLog, showTimeLog = _e === void 0 ? false : _e, _f = _a.isDisableFancy, isDisableFancy = _f === void 0 ? false : _f, _g = _a.isDisableEmoji, isDisableEmoji = _g === void 0 ? false : _g, _h = _a.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _h === void 0 ? false : _h, _j = _a.htmlTags, htmlTags = _j === void 0 ? false : _j, _k = _a.width, width = _k === void 0 ? 0 : _k, _l = _a.breaks, breaks = _l === void 0 ? true : _l, _m = _a.typographer, typographer = _m === void 0 ? false : _m, _o = _a.linkify, linkify = _o === void 0 ? false : _o, _p = _a.xhtmlOut, xhtmlOut = _p === void 0 ? false : _p, _q = _a.outMath, outMath = _q === void 0 ? {} : _q, _r = _a.mathJax, mathJax = _r === void 0 ? {} : _r, _s = _a.htmlSanitize, htmlSanitize = _s === void 0 ? {} : _s, _t = _a.smiles, smiles = _t === void 0 ? {} : _t, _u = _a.openLinkInNewWindow, openLinkInNewWindow = _u === void 0 ? true : _u, _v = _a.enableFileLinks, enableFileLinks = _v === void 0 ? false : _v, _w = _a.validateLink, validateLink = _w === void 0 ? null : _w, _x = _a.accessibility, accessibility = _x === void 0 ? null : _x, _y = _a.nonumbers, nonumbers = _y === void 0 ? false : _y, _z = _a.showPageBreaks, showPageBreaks = _z === void 0 ? false : _z, _0 = _a.centerImages, centerImages = _0 === void 0 ? true : _0, _1 = _a.centerTables, centerTables = _1 === void 0 ? true : _1, _2 = _a.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _2 === void 0 ? false : _2, _3 = _a.addPositionsToTokens, addPositionsToTokens = _3 === void 0 ? false : _3, _4 = _a.highlights, highlights = _4 === void 0 ? [] : _4, _5 = _a.parserErrors, parserErrors = _5 === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _5;
var _a = this.props, text = _a.text, _b = _a.alignMathBlock, alignMathBlock = _b === void 0 ? 'center' : _b, _c = _a.display, display = _c === void 0 ? 'block' : _c, _d = _a.isCheckFormula, isCheckFormula = _d === void 0 ? false : _d, _e = _a.showTimeLog, showTimeLog = _e === void 0 ? false : _e, _f = _a.isDisableFancy, isDisableFancy = _f === void 0 ? false : _f, _g = _a.isDisableEmoji, isDisableEmoji = _g === void 0 ? false : _g, _h = _a.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _h === void 0 ? false : _h, _j = _a.htmlTags, htmlTags = _j === void 0 ? false : _j, _k = _a.width, width = _k === void 0 ? 0 : _k, _l = _a.breaks, breaks = _l === void 0 ? true : _l, _m = _a.typographer, typographer = _m === void 0 ? false : _m, _o = _a.linkify, linkify = _o === void 0 ? false : _o, _p = _a.xhtmlOut, xhtmlOut = _p === void 0 ? false : _p, _q = _a.outMath, outMath = _q === void 0 ? {} : _q, _r = _a.mathJax, mathJax = _r === void 0 ? {} : _r, _s = _a.htmlSanitize, htmlSanitize = _s === void 0 ? {} : _s, _t = _a.smiles, smiles = _t === void 0 ? {} : _t, _u = _a.openLinkInNewWindow, openLinkInNewWindow = _u === void 0 ? true : _u, _v = _a.enableFileLinks, enableFileLinks = _v === void 0 ? false : _v, _w = _a.validateLink, validateLink = _w === void 0 ? null : _w, _x = _a.accessibility, accessibility = _x === void 0 ? null : _x, _y = _a.nonumbers, nonumbers = _y === void 0 ? false : _y, _z = _a.showPageBreaks, showPageBreaks = _z === void 0 ? false : _z, _0 = _a.centerImages, centerImages = _0 === void 0 ? true : _0, _1 = _a.centerTables, centerTables = _1 === void 0 ? true : _1, _2 = _a.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _2 === void 0 ? false : _2, _3 = _a.addPositionsToTokens, addPositionsToTokens = _3 === void 0 ? false : _3, _4 = _a.highlights, highlights = _4 === void 0 ? [] : _4, _5 = _a.parserErrors, parserErrors = _5 === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _5, _6 = _a.codeHighlight, codeHighlight = _6 === void 0 ? {} : _6;
var disableRules = isDisableFancy ? mathpix_markdown_model_1.MathpixMarkdownModel.disableFancyArrayDef : this.props.disableRules || [];

@@ -41,3 +41,4 @@ var markdownItOptions = {

highlights: highlights,
parserErrors: parserErrors
parserErrors: parserErrors,
codeHighlight: codeHighlight
};

@@ -44,0 +45,0 @@ mathpix_markdown_model_1.MathpixMarkdownModel.setOptions(disableRules, isCheckFormula, showTimeLog);

4

lib/index.d.ts

@@ -5,3 +5,3 @@ import MathpixLoader from './components/mathpix-loader';

import { mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, mdPluginCollapsible, mdSetPositionsAndHighlight } from "./markdown/mdPluginConfigured";
import { MathpixMarkdownModel, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, TTocStyle, THighlight, ParserErrors } from "./mathpix-markdown-model";
import { MathpixMarkdownModel, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, TTocStyle, THighlight, ParserErrors, CodeHighlight } from "./mathpix-markdown-model";
import { ISmilesOptions } from './markdown/md-chemistry';

@@ -11,2 +11,2 @@ import { resetTheoremEnvironments } from './markdown/md-theorem/helper';

import { normalizeLink } from './helpers/normalize-link';
export { MathpixLoader, MathpixMarkdown, MathpixMarkdownModel, mathpixMarkdownPlugin, mdPluginCollapsible, mdSetPositionsAndHighlight, initMathpixMarkdown, mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, ISmilesOptions, resetTheoremEnvironments, TTocStyle, THighlight, ParserErrors, eLabelType, ILabel, getLabelsList, getLabelByKeyFromLabelsList, clearLabelsList, normalizeLink };
export { MathpixLoader, MathpixMarkdown, MathpixMarkdownModel, mathpixMarkdownPlugin, mdPluginCollapsible, mdSetPositionsAndHighlight, initMathpixMarkdown, mdPluginMathJax, mdPluginHighlightCode, mdPluginText, mdPluginTOC, mdPluginAnchor, mdPluginTableTabular, mdPluginList, mdPluginChemistry, TMarkdownItOptions, optionsMathpixMarkdown, TOutputMath, TOutputMathJax, THtmlSanitize, ISmilesOptions, resetTheoremEnvironments, TTocStyle, THighlight, CodeHighlight, ParserErrors, eLabelType, ILabel, getLabelsList, getLabelByKeyFromLabelsList, clearLabelsList, normalizeLink };

@@ -107,1 +107,5 @@ export declare const attr_value: string;

export declare const mathTokenTypes: string[];
export declare const codeHighlightDef: {
auto: boolean;
code: boolean;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mathTokenTypes = exports.terminatedRules = exports.mdSeparatorsDef = exports.csvSeparatorsDef = exports.tsvSeparatorsDef = exports.mathEnvironments = exports.latexEnvironments = exports.HIGHLIGHT_TEXT_COLOR = exports.HIGHLIGHT_COLOR = exports.closeTagTabular = exports.openTagTabular = exports.reMultiRow = exports.reMultiRowWithVPos = exports.reAddContentsLineG = exports.reAddContentsLine = exports.reSetCounterG = exports.reSetCounter = exports.defQED = exports.reNewCommandQedSymbolG = exports.reNewCommandQedSymbol = exports.defTheoremStyle = exports.reTheoremStyleG = exports.reTheoremStyle = exports.reNewTheoremUnNumbered = exports.reNewTheoremNumbered2 = exports.reNewTheoremNumbered = exports.reNewTheorem = exports.reNewTheoremUnNumberedInit = exports.reNewTheoremInit = exports.reNewTheoremG = exports.openTagProof = exports.openTagDescription = exports.openTag = exports.labelTagG = exports.labelTag = exports.closeTagSpan = exports.reSpan = exports.reOpenTagSmiles = exports.open_tag_smiles = exports.closeTagMML = exports.openTagMML = exports.attribute = exports.attr_value = void 0;
exports.codeHighlightDef = exports.mathTokenTypes = exports.terminatedRules = exports.mdSeparatorsDef = exports.csvSeparatorsDef = exports.tsvSeparatorsDef = exports.mathEnvironments = exports.latexEnvironments = exports.HIGHLIGHT_TEXT_COLOR = exports.HIGHLIGHT_COLOR = exports.closeTagTabular = exports.openTagTabular = exports.reMultiRow = exports.reMultiRowWithVPos = exports.reAddContentsLineG = exports.reAddContentsLine = exports.reSetCounterG = exports.reSetCounter = exports.defQED = exports.reNewCommandQedSymbolG = exports.reNewCommandQedSymbol = exports.defTheoremStyle = exports.reTheoremStyleG = exports.reTheoremStyle = exports.reNewTheoremUnNumbered = exports.reNewTheoremNumbered2 = exports.reNewTheoremNumbered = exports.reNewTheorem = exports.reNewTheoremUnNumberedInit = exports.reNewTheoremInit = exports.reNewTheoremG = exports.openTagProof = exports.openTagDescription = exports.openTag = exports.labelTagG = exports.labelTag = exports.closeTagSpan = exports.reSpan = exports.reOpenTagSmiles = exports.open_tag_smiles = exports.closeTagMML = exports.openTagMML = exports.attribute = exports.attr_value = void 0;
var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';

@@ -156,2 +156,6 @@ var unquoted = '[^"\'=<>`\\x00-\\x20]+';

exports.mathTokenTypes = ["display_math", "inline_math", "equation_math_not_number", "equation_math"];
exports.codeHighlightDef = {
auto: false,
code: true
};
//# sourceMappingURL=consts.js.map

@@ -10,3 +10,3 @@ "use strict";

var mdInit = function (options) {
var _a = options.htmlTags, htmlTags = _a === void 0 ? false : _a, _b = options.xhtmlOut, xhtmlOut = _b === void 0 ? false : _b, _c = options.width, width = _c === void 0 ? 1200 : _c, _d = options.breaks, breaks = _d === void 0 ? true : _d, _e = options.typographer, typographer = _e === void 0 ? true : _e, _f = options.linkify, linkify = _f === void 0 ? true : _f, _g = options.outMath, outMath = _g === void 0 ? {} : _g, _h = options.mathJax, mathJax = _h === void 0 ? {} : _h, _j = options.renderElement, renderElement = _j === void 0 ? {} : _j, _k = options.lineNumbering, lineNumbering = _k === void 0 ? false : _k, _l = options.startLine, startLine = _l === void 0 ? 0 : _l, _m = options.htmlSanitize, htmlSanitize = _m === void 0 ? true : _m, _o = options.smiles, smiles = _o === void 0 ? {} : _o, _p = options.forDocx, forDocx = _p === void 0 ? false : _p, _q = options.openLinkInNewWindow, openLinkInNewWindow = _q === void 0 ? true : _q, _r = options.isDisableEmoji, isDisableEmoji = _r === void 0 ? false : _r, _s = options.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _s === void 0 ? false : _s, _t = options.maxWidth, maxWidth = _t === void 0 ? '' : _t, _u = options.enableFileLinks, enableFileLinks = _u === void 0 ? false : _u, _v = options.validateLink, validateLink = _v === void 0 ? null : _v, _w = options.toc, toc = _w === void 0 ? {} : _w, _x = options.accessibility, accessibility = _x === void 0 ? null : _x, _y = options.nonumbers, nonumbers = _y === void 0 ? false : _y, _z = options.showPageBreaks, showPageBreaks = _z === void 0 ? false : _z, _0 = options.centerImages, centerImages = _0 === void 0 ? true : _0, _1 = options.centerTables, centerTables = _1 === void 0 ? true : _1, _2 = options.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _2 === void 0 ? false : _2, _3 = options.addPositionsToTokens, addPositionsToTokens = _3 === void 0 ? false : _3, _4 = options.highlights, highlights = _4 === void 0 ? [] : _4, _5 = options.parserErrors, parserErrors = _5 === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _5;
var _a = options.htmlTags, htmlTags = _a === void 0 ? false : _a, _b = options.xhtmlOut, xhtmlOut = _b === void 0 ? false : _b, _c = options.width, width = _c === void 0 ? 1200 : _c, _d = options.breaks, breaks = _d === void 0 ? true : _d, _e = options.typographer, typographer = _e === void 0 ? true : _e, _f = options.linkify, linkify = _f === void 0 ? true : _f, _g = options.outMath, outMath = _g === void 0 ? {} : _g, _h = options.mathJax, mathJax = _h === void 0 ? {} : _h, _j = options.renderElement, renderElement = _j === void 0 ? {} : _j, _k = options.lineNumbering, lineNumbering = _k === void 0 ? false : _k, _l = options.startLine, startLine = _l === void 0 ? 0 : _l, _m = options.htmlSanitize, htmlSanitize = _m === void 0 ? true : _m, _o = options.smiles, smiles = _o === void 0 ? {} : _o, _p = options.forDocx, forDocx = _p === void 0 ? false : _p, _q = options.openLinkInNewWindow, openLinkInNewWindow = _q === void 0 ? true : _q, _r = options.isDisableEmoji, isDisableEmoji = _r === void 0 ? false : _r, _s = options.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _s === void 0 ? false : _s, _t = options.maxWidth, maxWidth = _t === void 0 ? '' : _t, _u = options.enableFileLinks, enableFileLinks = _u === void 0 ? false : _u, _v = options.validateLink, validateLink = _v === void 0 ? null : _v, _w = options.toc, toc = _w === void 0 ? {} : _w, _x = options.accessibility, accessibility = _x === void 0 ? null : _x, _y = options.nonumbers, nonumbers = _y === void 0 ? false : _y, _z = options.showPageBreaks, showPageBreaks = _z === void 0 ? false : _z, _0 = options.centerImages, centerImages = _0 === void 0 ? true : _0, _1 = options.centerTables, centerTables = _1 === void 0 ? true : _1, _2 = options.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _2 === void 0 ? false : _2, _3 = options.addPositionsToTokens, addPositionsToTokens = _3 === void 0 ? false : _3, _4 = options.highlights, highlights = _4 === void 0 ? [] : _4, _5 = options.parserErrors, parserErrors = _5 === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _5, _6 = options.codeHighlight, codeHighlight = _6 === void 0 ? {} : _6;
var mmdOptions = {

@@ -31,3 +31,4 @@ width: width,

highlights: highlights,
parserErrors: parserErrors
parserErrors: parserErrors,
codeHighlight: codeHighlight
};

@@ -34,0 +35,0 @@ var md = require("markdown-it")({

@@ -13,3 +13,3 @@ "use strict";

var _a;
var _b = options.width, width = _b === void 0 ? 1200 : _b, _c = options.outMath, outMath = _c === void 0 ? {} : _c, _d = options.smiles, smiles = _d === void 0 ? {} : _d, _e = options.mathJax, mathJax = _e === void 0 ? {} : _e, _f = options.renderElement, renderElement = _f === void 0 ? {} : _f, _g = options.forDocx, forDocx = _g === void 0 ? false : _g, _h = options.forLatex, forLatex = _h === void 0 ? false : _h, _j = options.maxWidth, maxWidth = _j === void 0 ? '' : _j, _k = options.enableFileLinks, enableFileLinks = _k === void 0 ? false : _k, _l = options.validateLink, validateLink = _l === void 0 ? null : _l, _m = options.toc, toc = _m === void 0 ? {} : _m, _o = options.accessibility, accessibility = _o === void 0 ? null : _o, _p = options.nonumbers, nonumbers = _p === void 0 ? false : _p, _q = options.showPageBreaks, showPageBreaks = _q === void 0 ? false : _q, _r = options.centerImages, centerImages = _r === void 0 ? true : _r, _s = options.centerTables, centerTables = _s === void 0 ? true : _s, _t = options.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _t === void 0 ? false : _t, _u = options.addPositionsToTokens, addPositionsToTokens = _u === void 0 ? false : _u, _v = options.highlights, highlights = _v === void 0 ? [] : _v, _w = options.parserErrors, parserErrors = _w === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _w;
var _b = options.width, width = _b === void 0 ? 1200 : _b, _c = options.outMath, outMath = _c === void 0 ? {} : _c, _d = options.smiles, smiles = _d === void 0 ? {} : _d, _e = options.mathJax, mathJax = _e === void 0 ? {} : _e, _f = options.renderElement, renderElement = _f === void 0 ? {} : _f, _g = options.forDocx, forDocx = _g === void 0 ? false : _g, _h = options.forLatex, forLatex = _h === void 0 ? false : _h, _j = options.maxWidth, maxWidth = _j === void 0 ? '' : _j, _k = options.enableFileLinks, enableFileLinks = _k === void 0 ? false : _k, _l = options.validateLink, validateLink = _l === void 0 ? null : _l, _m = options.toc, toc = _m === void 0 ? {} : _m, _o = options.accessibility, accessibility = _o === void 0 ? null : _o, _p = options.nonumbers, nonumbers = _p === void 0 ? false : _p, _q = options.showPageBreaks, showPageBreaks = _q === void 0 ? false : _q, _r = options.centerImages, centerImages = _r === void 0 ? true : _r, _s = options.centerTables, centerTables = _s === void 0 ? true : _s, _t = options.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _t === void 0 ? false : _t, _u = options.addPositionsToTokens, addPositionsToTokens = _u === void 0 ? false : _u, _v = options.highlights, highlights = _v === void 0 ? [] : _v, _w = options.parserErrors, parserErrors = _w === void 0 ? mathpix_markdown_model_1.ParserErrors.show : _w, _x = options.codeHighlight, codeHighlight = _x === void 0 ? {} : _x;
Object.assign(md.options, smiles);

@@ -33,3 +33,4 @@ Object.assign(md.options, {

highlights: highlights,
parserErrors: parserErrors
parserErrors: parserErrors,
codeHighlight: codeHighlight
});

@@ -42,3 +43,3 @@ md

.use((0, mdPluginConfigured_1.mdPluginText)())
.use(mdPluginConfigured_1.mdPluginHighlightCode, { auto: false })
.use(mdPluginConfigured_1.mdPluginHighlightCode, codeHighlight)
.use(mdPluginConfigured_1.mdPluginAnchor)

@@ -45,0 +46,0 @@ .use(mdPluginConfigured_1.mdPluginTOC, { toc: toc });

@@ -1,8 +0,2 @@

declare const highlightjs: {
(md: any, opts: any): void;
defaults: {
auto: boolean;
code: boolean;
};
};
declare const highlightjs: (md: any, opts: any) => void;
export default highlightjs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var highlight_js_1 = require("highlight.js");
var escapeHtml = require('markdown-it/lib/common/utils').escapeHtml;
var rules_1 = require("./rules");
var consts_1 = require("./common/consts");
var maybe = function (f) {

@@ -14,2 +17,8 @@ try {

var highlight = function (code, lang) {
// Looks up a language by name or alias.
// Returns the language object if found, undefined otherwise.
var langObj = highlight_js_1.default.getLanguage(lang);
if (langObj === undefined) {
return '';
}
if (lang.toLowerCase() === 'latex')

@@ -22,28 +31,64 @@ lang = 'tex';

// Highlight with given language or automatically.
var highlightAuto = function (code, lang) { return (lang
? highlight(code, lang)
: maybe(function () { return highlight_js_1.default.highlightAuto(code).value; }) || ''); };
var highlightAuto = function (code, lang) {
// Looks up a language by name or alias.
// Returns the language object if found, undefined otherwise.
var langObj = highlight_js_1.default.getLanguage(lang);
return lang && langObj !== undefined
? highlight(code, lang)
: maybe(function () { return highlight_js_1.default.highlightAuto(code).value; }) || '';
};
// Wrap a render function to add `hljs` class to code blocks.
var wrap = function (render) { return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
// const wrap = render => (...args) => {
var wrapFence = function (render) { return function (tokens, idx, options, env, slf) {
var html = render.apply(render, [tokens, idx, options, env, slf]);
html = html
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">');
if (options === null || options === void 0 ? void 0 : options.lineNumbering) {
var line = void 0, endLine = void 0, listLine = void 0;
if (tokens[idx].map && tokens[idx].level === 0) {
line = options.startLine + tokens[idx].map[0];
endLine = options.startLine + tokens[idx].map[1];
listLine = [];
for (var i = line; i < endLine; i++) {
listLine.push(i);
}
tokens[idx].attrJoin("class", rules_1.PREVIEW_PARAGRAPH_PREFIX + String(line)
+ ' ' + rules_1.PREVIEW_LINE_CLASS + ' ' + listLine.join(' '));
tokens[idx].attrJoin("data_line_start", "".concat(String(line)));
tokens[idx].attrJoin("data_line_end", "".concat(String(endLine - 1)));
tokens[idx].attrJoin("data_line", "".concat(String([line, endLine])));
tokens[idx].attrJoin("count_line", "".concat(String(endLine - line)));
html = html.replace('<pre>', '<pre' + slf.renderAttrs(tokens[idx]) + '>');
}
}
return (render.apply(render, args)
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">'));
return html;
}; };
var highlight_code_block = function (tokens, idx, options, env, slf) {
var token = tokens[idx];
var _a = options.codeHighlight, codeHighlight = _a === void 0 ? {} : _a;
codeHighlight = Object.assign({}, consts_1.codeHighlightDef, codeHighlight);
var _b = codeHighlight.code, code = _b === void 0 ? true : _b;
var highlighted = code && options.highlight
? options.highlight(token.content, '') || escapeHtml(token.content)
: escapeHtml(token.content);
return '<pre' + slf.renderAttrs(token) + '><code>' +
highlighted +
'</code></pre>\n';
};
var wrap = function (render) { return function (tokens, idx, options, env, slf) { return (render.apply(render, [tokens, idx, options, env, slf])
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">')); }; };
var highlightjs = function (md, opts) {
opts = Object.assign({}, highlightjs.defaults, opts);
var _a;
opts = Object.assign({}, consts_1.codeHighlightDef, opts);
md.options.highlight = opts.auto ? highlightAuto : highlight;
md.renderer.rules.fence = wrap(md.renderer.rules.fence);
md.renderer.rules.fence = wrapFence(md.renderer.rules.fence);
if (opts.code) {
md.renderer.rules.code_block = wrap(md.renderer.rules.code_block);
md.renderer.rules.code_block = ((_a = md.options) === null || _a === void 0 ? void 0 : _a.lineNumbering)
? wrap(rules_1.code_block_injectLineNumbers)
: wrap(highlight_code_block);
}
};
highlightjs.defaults = {
auto: true,
code: true
};
exports.default = highlightjs;
//# sourceMappingURL=mdHighlightCodePlugin.js.map

@@ -9,9 +9,3 @@ /**

export declare const mdPluginText: () => (md: MarkdownIt) => void;
export declare const mdPluginHighlightCode: {
(md: any, opts: any): void;
defaults: {
auto: boolean;
code: boolean;
};
};
export declare const mdPluginHighlightCode: (md: any, opts: any) => void;
export declare const mdPluginTOC: (md: MarkdownIt, opts: any) => void;

@@ -18,0 +12,0 @@ export declare const mdPluginAnchor: {

export declare const PREVIEW_PARAGRAPH_PREFIX = "preview-paragraph-";
export declare const PREVIEW_LINE_CLASS = "preview-line";
export declare function code_block_injectLineNumbers(tokens: any, idx: any, options: any, env: any, slf: any): string;
/** overwrite paragraph_open and close rule to inject line number */

@@ -4,0 +5,0 @@ export declare function withLineNumbers(renderer: any): any;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectRenderRules = exports.injectLabelIdToParagraph = exports.withLineNumbers = exports.PREVIEW_LINE_CLASS = exports.PREVIEW_PARAGRAPH_PREFIX = void 0;
exports.injectRenderRules = exports.injectLabelIdToParagraph = exports.withLineNumbers = exports.code_block_injectLineNumbers = exports.PREVIEW_LINE_CLASS = exports.PREVIEW_PARAGRAPH_PREFIX = void 0;
var sanitize_1 = require("./sanitize");

@@ -8,2 +8,3 @@ var inline_styles_1 = require("./inline-styles");

var utils_1 = require("./utils");
var consts_1 = require("./common/consts");
exports.PREVIEW_PARAGRAPH_PREFIX = "preview-paragraph-";

@@ -129,6 +130,13 @@ exports.PREVIEW_LINE_CLASS = "preview-line";

var token = tokens[idx];
var _a = options.codeHighlight, codeHighlight = _a === void 0 ? {} : _a;
codeHighlight = Object.assign({}, consts_1.codeHighlightDef, codeHighlight);
var _b = codeHighlight.code, code = _b === void 0 ? true : _b;
var highlighted = code && options.highlight
? options.highlight(token.content, '') || escapeHtml(token.content)
: escapeHtml(token.content);
return '<pre' + slf.renderAttrs(token) + '><code>' +
escapeHtml(tokens[idx].content) +
highlighted +
'</code></pre>\n';
}
exports.code_block_injectLineNumbers = code_block_injectLineNumbers;
/** overwrite paragraph_open and close rule to inject line number */

@@ -144,5 +152,8 @@ function withLineNumbers(renderer) {

= injectLineNumbers;
renderer.renderer.rules.code_block
// = renderer.renderer.rules.fence
= code_block_injectLineNumbers;
var _a = renderer.options.codeHighlight, codeHighlight = _a === void 0 ? {} : _a;
codeHighlight = Object.assign({}, consts_1.codeHighlightDef, codeHighlight);
var _b = codeHighlight.code, code = _b === void 0 ? true : _b;
if (!code) {
renderer.renderer.rules.code_block = code_block_injectLineNumbers;
}
return renderer;

@@ -149,0 +160,0 @@ }

@@ -42,2 +42,3 @@ import { Property } from 'csstype';

parserErrors?: ParserErrors;
codeHighlight?: CodeHighlight;
}

@@ -84,2 +85,3 @@ export type TMarkdownItOptions = {

parserErrors?: ParserErrors;
codeHighlight?: CodeHighlight;
};

@@ -137,2 +139,6 @@ export type TOutputMath = {

};
export type CodeHighlight = {
auto?: boolean;
code?: boolean;
};
export declare enum TTocStyle {

@@ -139,0 +145,0 @@ summary = "summary",

@@ -292,3 +292,3 @@ "use strict";

this.render = function (text, options) {
var _a = options || {}, _b = _a.alignMathBlock, alignMathBlock = _b === void 0 ? 'center' : _b, _c = _a.display, display = _c === void 0 ? 'block' : _c, _d = _a.isCheckFormula, isCheckFormula = _d === void 0 ? false : _d, _e = _a.showTimeLog, showTimeLog = _e === void 0 ? false : _e, _f = _a.isDisableFancy, isDisableFancy = _f === void 0 ? false : _f, _g = _a.isDisableEmoji, isDisableEmoji = _g === void 0 ? false : _g, _h = _a.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _h === void 0 ? false : _h, _j = _a.fontSize, fontSize = _j === void 0 ? null : _j, _k = _a.padding, padding = _k === void 0 ? null : _k, _l = _a.htmlTags, htmlTags = _l === void 0 ? false : _l, _m = _a.width, width = _m === void 0 ? 0 : _m, _o = _a.showToc, showToc = _o === void 0 ? false : _o, _p = _a.overflowY, overflowY = _p === void 0 ? 'unset' : _p, _q = _a.breaks, breaks = _q === void 0 ? true : _q, _r = _a.typographer, typographer = _r === void 0 ? true : _r, _s = _a.linkify, linkify = _s === void 0 ? true : _s, _t = _a.xhtmlOut, xhtmlOut = _t === void 0 ? false : _t, _u = _a.outMath, outMath = _u === void 0 ? {} : _u, _v = _a.mathJax, mathJax = _v === void 0 ? {} : _v, _w = _a.htmlSanitize, htmlSanitize = _w === void 0 ? {} : _w, _x = _a.smiles, smiles = _x === void 0 ? {} : _x, _y = _a.openLinkInNewWindow, openLinkInNewWindow = _y === void 0 ? true : _y, _z = _a.maxWidth, maxWidth = _z === void 0 ? '' : _z, _0 = _a.enableFileLinks, enableFileLinks = _0 === void 0 ? false : _0, _1 = _a.validateLink, validateLink = _1 === void 0 ? null : _1, _2 = _a.toc, toc = _2 === void 0 ? {} : _2, _3 = _a.accessibility, accessibility = _3 === void 0 ? null : _3, _4 = _a.nonumbers, nonumbers = _4 === void 0 ? false : _4, _5 = _a.showPageBreaks, showPageBreaks = _5 === void 0 ? false : _5, _6 = _a.centerImages, centerImages = _6 === void 0 ? true : _6, _7 = _a.centerTables, centerTables = _7 === void 0 ? true : _7, _8 = _a.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _8 === void 0 ? false : _8, _9 = _a.addPositionsToTokens, addPositionsToTokens = _9 === void 0 ? false : _9, _10 = _a.highlights, highlights = _10 === void 0 ? [] : _10, _11 = _a.parserErrors, parserErrors = _11 === void 0 ? ParserErrors.show : _11;
var _a = options || {}, _b = _a.alignMathBlock, alignMathBlock = _b === void 0 ? 'center' : _b, _c = _a.display, display = _c === void 0 ? 'block' : _c, _d = _a.isCheckFormula, isCheckFormula = _d === void 0 ? false : _d, _e = _a.showTimeLog, showTimeLog = _e === void 0 ? false : _e, _f = _a.isDisableFancy, isDisableFancy = _f === void 0 ? false : _f, _g = _a.isDisableEmoji, isDisableEmoji = _g === void 0 ? false : _g, _h = _a.isDisableEmojiShortcuts, isDisableEmojiShortcuts = _h === void 0 ? false : _h, _j = _a.fontSize, fontSize = _j === void 0 ? null : _j, _k = _a.padding, padding = _k === void 0 ? null : _k, _l = _a.htmlTags, htmlTags = _l === void 0 ? false : _l, _m = _a.width, width = _m === void 0 ? 0 : _m, _o = _a.showToc, showToc = _o === void 0 ? false : _o, _p = _a.overflowY, overflowY = _p === void 0 ? 'unset' : _p, _q = _a.breaks, breaks = _q === void 0 ? true : _q, _r = _a.typographer, typographer = _r === void 0 ? true : _r, _s = _a.linkify, linkify = _s === void 0 ? true : _s, _t = _a.xhtmlOut, xhtmlOut = _t === void 0 ? false : _t, _u = _a.outMath, outMath = _u === void 0 ? {} : _u, _v = _a.mathJax, mathJax = _v === void 0 ? {} : _v, _w = _a.htmlSanitize, htmlSanitize = _w === void 0 ? {} : _w, _x = _a.smiles, smiles = _x === void 0 ? {} : _x, _y = _a.openLinkInNewWindow, openLinkInNewWindow = _y === void 0 ? true : _y, _z = _a.maxWidth, maxWidth = _z === void 0 ? '' : _z, _0 = _a.enableFileLinks, enableFileLinks = _0 === void 0 ? false : _0, _1 = _a.validateLink, validateLink = _1 === void 0 ? null : _1, _2 = _a.toc, toc = _2 === void 0 ? {} : _2, _3 = _a.accessibility, accessibility = _3 === void 0 ? null : _3, _4 = _a.nonumbers, nonumbers = _4 === void 0 ? false : _4, _5 = _a.showPageBreaks, showPageBreaks = _5 === void 0 ? false : _5, _6 = _a.centerImages, centerImages = _6 === void 0 ? true : _6, _7 = _a.centerTables, centerTables = _7 === void 0 ? true : _7, _8 = _a.enableCodeBlockRuleForLatexCommands, enableCodeBlockRuleForLatexCommands = _8 === void 0 ? false : _8, _9 = _a.addPositionsToTokens, addPositionsToTokens = _9 === void 0 ? false : _9, _10 = _a.highlights, highlights = _10 === void 0 ? [] : _10, _11 = _a.parserErrors, parserErrors = _11 === void 0 ? ParserErrors.show : _11, _12 = _a.codeHighlight, codeHighlight = _12 === void 0 ? {} : _12;
var disableRules = isDisableFancy ? _this.disableFancyArrayDef : options ? options.disableRules || [] : [];

@@ -332,3 +332,4 @@ if (showToc) {

highlights: highlights,
parserErrors: parserErrors
parserErrors: parserErrors,
codeHighlight: codeHighlight
};

@@ -335,0 +336,0 @@ var styleFontSize = fontSize ? " font-size: ".concat(options.fontSize, "px;") : '';

{
"name": "mathpix-markdown-it",
"version": "1.2.5",
"version": "1.2.6",
"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": [

@@ -671,2 +671,3 @@ # mathpix-markdown-it

| `parserErrors` | [ParserErrors](https://github.com/Mathpix/mathpix-markdown-it#parsererrors);*`{}`* | Sets options to output parser errors for equations and tabular |
| `codeHighlight` | [CodeHighlight](https://github.com/Mathpix/mathpix-markdown-it#codehighlight);*`{}`* | Sets options to highlight code block |

@@ -720,2 +721,3 @@

| `parserErrors` | [ParserErrors](https://github.com/Mathpix/mathpix-markdown-it#parsererrors);*`{}`* | Sets options to output parser errors for equations and tabular |
| `codeHighlight` | [CodeHighlight](https://github.com/Mathpix/mathpix-markdown-it#codehighlight);*`{}`* | Sets options to highlight code block |

@@ -750,2 +752,3 @@ ### optionsMathpixMarkdown

| `parserErrors` | [ParserErrors](https://github.com/Mathpix/mathpix-markdown-it#parsererrors);*`{}`* | Sets options to output parser errors for equations and tabular |
| `codeHighlight` | [CodeHighlight](https://github.com/Mathpix/mathpix-markdown-it#codehighlight);*`{}`* | Sets options to highlight code block |

@@ -829,2 +832,9 @@ ### TOutputMath

### CodeHighlight
| | type&nbsp;*`default`* | |
|--------------|------------------------|---------------------------------------------------------------------------------------------------------------|
| `auto` | boolean&nbsp;*`false`* | Highlighting with language detection |
| `code` | boolean&nbsp;*`true`* | Add code highlighting for a code block which created by indenting. To auto-detect the language, set auto=true |
`sre` Has different loaders for node and browser.

@@ -831,0 +841,0 @@

Sorry, the diff of this file is not supported yet

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

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

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

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