Skip to content
Snippets Groups Projects
Commit 332d6e41 authored by iktakahiro's avatar iktakahiro
Browse files

Merge branch 'release/3.0.4'

parents 9fc7e66d e8e33840
No related branches found
No related tags found
No related merge requests found
......@@ -152,6 +152,15 @@ function math_block(state, start, end, silent){
return true;
}
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
module.exports = function math_plugin(md, options) {
// Default options
......@@ -165,7 +174,7 @@ module.exports = function math_plugin(md, options) {
}
catch(error){
if(options.throwOnError){ console.log(error); }
return latex;
return `<span class='katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</span>`;
}
};
......@@ -176,11 +185,11 @@ module.exports = function math_plugin(md, options) {
var katexBlock = function(latex){
options.displayMode = true;
try{
return "<p>" + katex.renderToString(latex, options) + "</p>";
return "<p class='katex-block'>" + katex.renderToString(latex, options) + "</p>";
}
catch(error){
if(options.throwOnError){ console.log(error); }
return latex;
return `<p class='katex-block katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</p>`;
}
}
......
{
"name": "@iktakahiro/markdown-it-katex",
"version": "3.0.3",
"version": "3.0.4",
"description": "Fast math support for markdown-it with KaTeX",
"main": "index.js",
"scripts": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment