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

Function _findObserveGroups

static/katex/contrib/mhchem.js:619–650  ·  view source on GitHub ↗
(input, i, endChars)

Source from the content-addressed store, hash-verified

617
618
619 var _findObserveGroups = function _findObserveGroups(input, i, endChars) {
620 var braces = 0;
621
622 while (i < input.length) {
623 var a = input.charAt(i);
624
625 var match = _match(input.substr(i), endChars);
626
627 if (match !== null && braces === 0) {
628 return {
629 endMatchBegin: i,
630 endMatchEnd: i + match.length
631 };
632 } else if (a === "{") {
633 braces++;
634 } else if (a === "}") {
635 if (braces === 0) {
636 throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"];
637 } else {
638 braces--;
639 }
640 }
641
642 i++;
643 }
644
645 if (braces > 0) {
646 return null;
647 }
648
649 return null;
650 };
651
652 var match = _match(input, begExcl);
653

Callers 1

mhchem.jsFile · 0.70

Calls 1

_matchFunction · 0.70

Tested by

no test coverage detected