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

Function renderElem

static/katex/contrib/auto-render.js:267–291  ·  view source on GitHub ↗
(elem, optionsCopy)

Source from the content-addressed store, hash-verified

265};
266
267var renderElem = function renderElem(elem, optionsCopy) {
268 for (var i = 0; i < elem.childNodes.length; i++) {
269 var childNode = elem.childNodes[i];
270
271 if (childNode.nodeType === 3) {
272 // Text node
273 var frag = auto_render_renderMathInText(childNode.textContent, optionsCopy);
274 i += frag.childNodes.length - 1;
275 elem.replaceChild(frag, childNode);
276 } else if (childNode.nodeType === 1) {
277 (function () {
278 // Element node
279 var className = ' ' + childNode.className + ' ';
280 var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(function (x) {
281 return className.indexOf(' ' + x + ' ') === -1;
282 });
283
284 if (shouldRender) {
285 renderElem(childNode, optionsCopy);
286 }
287 })();
288 } // Otherwise, it's something else, and ignore it.
289
290 }
291};
292
293var renderMathInElement = function renderMathInElement(elem, options) {
294 if (!elem) {

Callers 1

renderMathInElementFunction · 0.70

Calls 1

Tested by

no test coverage detected