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

Function findEndOfMath

static/katex/contrib/auto-render.js:116–140  ·  view source on GitHub ↗
(delimiter, text, startIndex)

Source from the content-addressed store, hash-verified

114// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js
115/* eslint no-constant-condition:0 */
116var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) {
117 // Adapted from
118 // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
119 var index = startIndex;
120 var braceLevel = 0;
121 var delimLength = delimiter.length;
122
123 while (index < text.length) {
124 var character = text[index];
125
126 if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) {
127 return index;
128 } else if (character === "\\") {
129 index++;
130 } else if (character === "{") {
131 braceLevel++;
132 } else if (character === "}") {
133 braceLevel--;
134 }
135
136 index++;
137 }
138
139 return -1;
140};
141
142var splitAtDelimiters = function splitAtDelimiters(startData, leftDelim, rightDelim, display) {
143 var finalData = [];

Callers 1

splitAtDelimitersFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected