Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
md.renderer.rules.code_inline = (tokens, idx, options, env, slf) => {
let code = tokens[idx].content;
if (code.startsWith("math")) {
code = `katex ${asciimath2latex(code.substr(4, code.length - 2))}`;
}
// inline math
if (code.startsWith("katex")) {
code = code.substr(5, code.length - 2);
try {
return katex.renderToString(code);
} catch (err) {
return `<code>${err}</code>`;
}
}
return temp1(tokens, idx, options, env, slf);
};
return mathBlock(code.split(/(?:\n\s*){2,}/).map(item => asciimath2latex(item)).join("\n\n"));
}