react-latex
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -33,18 +33,17 @@ "use strict"; | ||
string = string.replace(/(<([^>]+)>)/gi, ""); | ||
var regularExpression = /\$\$[\s\S]+?\$\$|\$[\s\S]+?\$/g; | ||
var regularExpression = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]|\\\([\s\S]+?\\\)|\$[\s\S]+?\$/g; | ||
var blockRegularExpression = /\$\$[\s\S]+?\$\$|\\\[[\s\S]+?\\\]/g; | ||
var stripDollars = function stripDollars(stringToStrip) { | ||
if (stringToStrip[1] === "$") { | ||
stringToStrip = stringToStrip.slice(2, -2); | ||
} else { | ||
stringToStrip = stringToStrip.slice(1, -1); | ||
} | ||
return stringToStrip[0] === "$" && stringToStrip[1] !== "$" ? stringToStrip.slice(1, -1) : stringToStrip.slice(2, -2); | ||
}; | ||
return stringToStrip; | ||
var getDisplay = function getDisplay(stringToDisplay) { | ||
return stringToDisplay.match(blockRegularExpression) ? "block" : "inline"; | ||
}; | ||
var renderLatexString = function renderLatexString(s) { | ||
var renderLatexString = function renderLatexString(s, t) { | ||
var renderedString = void 0; | ||
try { | ||
renderedString = _katex2.default.renderToString(s, options); | ||
renderedString = _katex2.default.renderToString(s, t === "block" ? Object.assign(options, { displayMode: true }) : options); | ||
} catch (err) { | ||
@@ -71,3 +70,3 @@ console.error("couldn`t convert string", s); | ||
string: stripDollars(latexMatch[index]), | ||
type: "latex" | ||
type: getDisplay(latexMatch[index]) | ||
}); | ||
@@ -88,3 +87,3 @@ } | ||
} | ||
return renderLatexString(r.string); | ||
return renderLatexString(r.string, r.type); | ||
}); | ||
@@ -91,0 +90,0 @@ |
{ | ||
"name": "react-latex", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "React component to render latex strings", | ||
@@ -5,0 +5,0 @@ "repository": "zzish/react-latex", |
@@ -1,2 +0,2 @@ | ||
# react-latex [![NPM version][npm-image]][npm-url][![Dependency Status][daviddm-image]][daviddm-url][![Build Status][travis-image]][travis-url] | ||
# react-latex [![NPM version][npm-image]][npm-url] | ||
@@ -3,0 +3,0 @@ > React component to render latex strings, based on [Katex](https://github.com/Khan/KaTeX) |
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
11433
150