mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
Add ignore option for class names (#1555)
* Add ignore option for class names This change adds another option for ignoring nodes for rendering similar to `ignoreTags`. The new option `ignoreClasses` can hold an array of strings representing class names that should be ignored if they are in a node's class list. This can be desirable in dynamic environments. * Adhere to CI rules for styling * Add documentation for new option * Exchange classList property with IE9 compatible code * Harmonize variable names * Add default for ignoredClasses
This commit is contained in:
@@ -61,8 +61,11 @@ const renderElem = function(elem, optionsCopy) {
|
||||
elem.replaceChild(frag, childNode);
|
||||
} else if (childNode.nodeType === 1) {
|
||||
// Element node
|
||||
const className = ' ' + childNode.className + ' ';
|
||||
const shouldRender = optionsCopy.ignoredTags.indexOf(
|
||||
childNode.nodeName.toLowerCase()) === -1;
|
||||
childNode.nodeName.toLowerCase()) === -1 &&
|
||||
optionsCopy.ignoredClasses.every(
|
||||
x => className.indexOf(' ' + x + ' ') === -1);
|
||||
|
||||
if (shouldRender) {
|
||||
renderElem(childNode, optionsCopy);
|
||||
@@ -90,6 +93,8 @@ const defaultAutoRenderOptions = {
|
||||
"script", "noscript", "style", "textarea", "pre", "code",
|
||||
],
|
||||
|
||||
ignoredClasses: [],
|
||||
|
||||
errorCallback: function(msg, err) {
|
||||
console.error(msg, err);
|
||||
},
|
||||
|
Reference in New Issue
Block a user