(elem, options)
| 171 | }; |
| 172 | |
| 173 | const renderMathInElement = function renderMathInElement(elem, options) { |
| 174 | if (!elem) { |
| 175 | throw new Error("No element provided to render"); |
| 176 | } |
| 177 | |
| 178 | const optionsCopy = {}; // Object.assign(optionsCopy, option) |
| 179 | |
| 180 | for (const option in options) { |
| 181 | if (options.hasOwnProperty(option)) { |
| 182 | optionsCopy[option] = options[option]; |
| 183 | } |
| 184 | } // default options |
| 185 | |
| 186 | |
| 187 | optionsCopy.delimiters = optionsCopy.delimiters || [{ |
| 188 | left: "$$", |
| 189 | right: "$$", |
| 190 | display: true |
| 191 | }, { |
| 192 | left: "\\(", |
| 193 | right: "\\)", |
| 194 | display: false |
| 195 | }, // LaTeX uses $…$, but it ruins the display of normal `$` in text: |
| 196 | // {left: "$", right: "$", display: false}, |
| 197 | // \[…\] must come last in this array. Otherwise, renderMathInElement |
| 198 | // will search for \[ before it searches for $$ or \( |
| 199 | // That makes it susceptible to finding a \\[0.3em] row delimiter and |
| 200 | // treating it as if it were the start of a KaTeX math zone. |
| 201 | { |
| 202 | left: "\\[", |
| 203 | right: "\\]", |
| 204 | display: true |
| 205 | }]; |
| 206 | optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code"]; |
| 207 | optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; |
| 208 | optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different |
| 209 | // math elements within a single call to `renderMathInElement`. |
| 210 | |
| 211 | optionsCopy.macros = optionsCopy.macros || {}; |
| 212 | renderElem(elem, optionsCopy); |
| 213 | }; |
| 214 | |
| 215 | export default renderMathInElement; |
nothing calls this directly
no test coverage detected