MCPcopy Create free account
hub / github.com/TruthHun/BookStack / renderMathInElement

Function renderMathInElement

static/katex/contrib/auto-render.js:293–333  ·  view source on GitHub ↗
(elem, options)

Source from the content-addressed store, hash-verified

291};
292
293var renderMathInElement = function renderMathInElement(elem, options) {
294 if (!elem) {
295 throw new Error("No element provided to render");
296 }
297
298 var optionsCopy = {}; // Object.assign(optionsCopy, option)
299
300 for (var option in options) {
301 if (options.hasOwnProperty(option)) {
302 optionsCopy[option] = options[option];
303 }
304 } // default options
305
306
307 optionsCopy.delimiters = optionsCopy.delimiters || [{
308 left: "$$",
309 right: "$$",
310 display: true
311 }, {
312 left: "\\(",
313 right: "\\)",
314 display: false
315 }, // LaTeX uses $…$, but it ruins the display of normal `$` in text:
316 // {left: "$", right: "$", display: false},
317 // \[…\] must come last in this array. Otherwise, renderMathInElement
318 // will search for \[ before it searches for $$ or \(
319 // That makes it susceptible to finding a \\[0.3em] row delimiter and
320 // treating it as if it were the start of a KaTeX math zone.
321 {
322 left: "\\[",
323 right: "\\]",
324 display: true
325 }];
326 optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code"];
327 optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || [];
328 optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different
329 // math elements within a single call to `renderMathInElement`.
330
331 optionsCopy.macros = optionsCopy.macros || {};
332 renderElem(elem, optionsCopy);
333};
334
335/* harmony default export */ var auto_render = __webpack_exports__["default"] = (renderMathInElement);
336

Callers

nothing calls this directly

Calls 1

renderElemFunction · 0.70

Tested by

no test coverage detected