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

Function _findObserveGroups

static/katex/contrib/mhchem.mjs:509–540  ·  view source on GitHub ↗
(input, i, endChars)

Source from the content-addressed store, hash-verified

507
508
509 var _findObserveGroups = function _findObserveGroups(input, i, endChars) {
510 var braces = 0;
511
512 while (i < input.length) {
513 var a = input.charAt(i);
514
515 var match = _match(input.substr(i), endChars);
516
517 if (match !== null && braces === 0) {
518 return {
519 endMatchBegin: i,
520 endMatchEnd: i + match.length
521 };
522 } else if (a === "{") {
523 braces++;
524 } else if (a === "}") {
525 if (braces === 0) {
526 throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"];
527 } else {
528 braces--;
529 }
530 }
531
532 i++;
533 }
534
535 if (braces > 0) {
536 return null;
537 }
538
539 return null;
540 };
541
542 var match = _match(input, begExcl);
543

Callers 1

mhchem.mjsFile · 0.70

Calls 1

_matchFunction · 0.70

Tested by

no test coverage detected