react-latex
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -30,5 +30,3 @@ "use strict"; | ||
var latexString = function latexString(string, options) { | ||
// Remove potential HTML | ||
string = string.replace(/(<([^>]+)>)/gi, ""); | ||
var latexify = function latexify(string, options) { | ||
var regularExpression = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]|\\\([\s\S]+?\\\)|\$[\s\S]+?\$/g; | ||
@@ -48,3 +46,4 @@ var blockRegularExpression = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]/g; | ||
try { | ||
renderedString = _katex2.default.renderToString(s, t === "block" ? Object.assign(options, { displayMode: true }) : options); | ||
// returns HTML markup | ||
renderedString = _katex2.default.renderToString(s, t === "block" ? Object.assign({ displayMode: true }, options) : options); | ||
} catch (err) { | ||
@@ -87,8 +86,9 @@ console.error("couldn`t convert string", s); | ||
} | ||
return renderLatexString(r.string, r.type); | ||
return _react2.default.createElement("span", { dangerouslySetInnerHTML: { __html: renderLatexString(r.string, r.type) } }); | ||
}); | ||
return newResult.join(" "); | ||
return newResult; | ||
}; | ||
// Returns list of spans with latex and non-latex strings. | ||
return processResult(result); | ||
@@ -124,20 +124,19 @@ }; | ||
return _react2.default.createElement("span", { | ||
dangerouslySetInnerHTML: { | ||
__html: latexString(children, { | ||
displayMode: displayMode, | ||
leqno: leqno, | ||
fleqn: fleqn, | ||
throwOnError: throwOnError, | ||
errorColor: errorColor, | ||
macros: macros, | ||
minRuleThickness: minRuleThickness, | ||
colorIsTextColor: colorIsTextColor, | ||
maxSize: maxSize, | ||
maxExpand: maxExpand, | ||
strict: strict, | ||
trust: trust | ||
}) | ||
} | ||
}); | ||
var renderUs = latexify(children, { displayMode: displayMode, | ||
leqno: leqno, | ||
fleqn: fleqn, | ||
throwOnError: throwOnError, | ||
errorColor: errorColor, | ||
macros: macros, | ||
minRuleThickness: minRuleThickness, | ||
colorIsTextColor: colorIsTextColor, | ||
maxSize: maxSize, | ||
maxExpand: maxExpand, | ||
strict: strict, | ||
trust: trust }); | ||
renderUs.unshift(null); | ||
renderUs.unshift('span'); //put everything in a span | ||
// spread renderUs out to children args | ||
return _react2.default.createElement.apply(null, renderUs); | ||
} | ||
@@ -144,0 +143,0 @@ }]); |
{ | ||
"name": "react-latex", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "React component to render latex strings", | ||
@@ -5,0 +5,0 @@ "repository": "zzish/react-latex", |
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
11471
148