rehype-katex
Advanced tools
Comparing version 0.2.3 to 1.0.0
18
index.js
@@ -26,7 +26,7 @@ const visit = require('unist-util-visit') | ||
if (opts.throwOnError == null) opts.throwOnError = false | ||
if (opts.errorColor == null) opts.errorColor = '#cc0000' | ||
return function transform (node, file) { | ||
visit(node, 'element', function (element) { | ||
const isInlineMath = isTag(element, 'span') && hasClass(element, 'inlineMath') | ||
const isMath = (opts.inlineDoubleDisplay && hasClass(element, 'inlineMathDouble')) || | ||
(isTag(element, 'div') && hasClass(element, 'math')) | ||
const isMath = (opts.inlineMathDoubleDisplay && hasClass(element, 'inlineMathDouble')) || (isTag(element, 'div') && hasClass(element, 'math')) | ||
@@ -47,7 +47,11 @@ if (isInlineMath || isMath) { | ||
) | ||
renderedValue = katex.renderToString(element.children[0].value, { | ||
displayMode: isMath, | ||
throwOnError: false, | ||
errorColor: opts.errorColor | ||
}, 'katex-parse-error') | ||
try { | ||
renderedValue = katex.renderToString(element.children[0].value, { | ||
displayMode: isMath, | ||
throwOnError: false, | ||
errorColor: opts.errorColor | ||
}) | ||
} catch (err) { | ||
renderedValue = '<code class="katex" style="color: ' + opts.errorColor + '">' + element.children[0].value + '</code>' | ||
} | ||
} | ||
@@ -54,0 +58,0 @@ } |
{ | ||
"name": "rehype-katex", | ||
"version": "0.2.3", | ||
"version": "1.0.0", | ||
"description": "KaTeX transform plugin for rehype", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4336
59
0