Search `[:~][\n ]`, returns next $pos after $marker on success or -1 on fail.
@param \Kaoken\MarkdownIt\RulesBlock\StateBlock $state
@param integer $line
@return int
960991
protected function skipMarker(&$state, $line)
    {
        $start = $state->bMarks[$line] + $state->tShift[$line];
        $max = $state->eMarks[$line];

        if ($start >= $max) { return -1; }

        // Check bullet
        $marker = $state->src[$start++];
        if ($marker !== '~' && $marker !== ':') { return -1; }

        $pos = $state->skipSpaces($start);

        // require space after ":"
        if ($start === $pos) { return -1; }

        // no empty definitions, e.g. "  : "
        if ($pos >= $max) { return -1; }

        return $start;
    }
1103883
@Override
  public void onOutputLine(String line) {
    if (waitLatch.getCount() > 0 && message != null && line.matches(message)) {
      waitLatch.countDown();
    }
  }
1164329
private function getLinesNumbers(string $line)
    {
        $matches = [];
        preg_match('/@@ -(.*) \+(.*) @@?(.*)/', $line, $matches);
        if (!strpos($matches[1], ',')) {
            // one line
            $this->originStartLine = $matches[1];
            $this->originEndLine = $matches[1];
        } else {
            list($this->originStartLine, $this->originEndLine) = explode(',', $matches[1]);
        }

        if (!strpos($matches[2], ',')) {
            // one line
            $this->destStartLine = $matches[2];
            $this->destEndLine = $matches[2];
        } else {
            list($this->destStartLine, $this->destEndLine) = explode(',', $matches[2]);
        }
    }
1128417
protected function determinePriority($state)
    {
        $priority = 0;

        if (array_key_exists($state, $this->stateToPriorityMap)) {
            $priority = $this->stateToPriorityMap[$state];
        }

        return $priority;
    }
717064
public function skipToken(&$state)
    {
        $pos = $state->pos;
        $rules = $this->ruler->getRules('');
        $maxNesting = $state->md->options->maxNesting;
        $cache = &$state->cache;
        $ok = false;

        if ( isset($cache[$pos])) {
            $state->pos = $cache[$pos];
            return;
        }

        if ($state->level < $maxNesting) {
            foreach ($rules as &$rule) {
                // Increment state.level and decrement it later to limit recursion.
                // It's harmless to do here, because no tokens are created. But ideally,
                // we'd need a separate private state variable for this purpose.
                //
                $state->level++;

                if( is_array($rule) )
                    $ok = $rule[0]->{$rule[1]}($state, true);
                else
                    $ok = $rule($state, true);

                $state->level--;

                if ($ok) break;
            }
        } else {
            // Too much nesting, just skip until the end of the paragraph.
            //
            // NOTE: this will cause links to behave incorrectly in the following case,
            //       when an amount of `[` is exactly equal to `maxNesting + 1`:
            //
            //       [[[[[[[[[[[[[[[[[[[[[foo]()
            //
            // TODO: remove this workaround when CM standard will allow nested links
            //       (we can replace it by preventing links from being parsed in
            //       validation mode)
            //
            $state->pos = $state->posMax;
        }

        if (!$ok) { $state->pos++; }
        $cache[$pos] = $state->pos;
    }
1141254
function parseBlockKatex(state, startLine, endLine) {
        var marker, len, params, nextLine, mem,
            haveEndMarker = false,
            pos = state.bMarks[startLine] + state.tShift[startLine],
            max = state.eMarks[startLine];
        var dollar = 0x24;

        if (pos + 1 > max) { return false; }

        marker = state.src.charCodeAt(pos);
        if (marker !== dollar) { return false; }

        // scan marker length
        mem = pos;
        pos = state.skipChars(pos, marker);
        len = pos - mem;

        if (len != 2)  { return false; }

        // search end of block
        nextLine = startLine;

        for (;;) {
            ++nextLine;
            if (nextLine >= endLine) {

                // unclosed block should be autoclosed by end of document.
                // also block seems to be autoclosed by end of parent
                break;
            }

            pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
            max = state.eMarks[nextLine];

            if (pos < max && state.tShift[nextLine] < state.blkIndent) {

                // non-empty line with negative indent should stop the list:
                // - ```
                //  test
                break;
            }

            if (state.src.charCodeAt(pos) !== dollar) { continue };

            if (state.tShift[nextLine] - state.blkIndent >= 4) {

                // closing fence should be indented less than 4 spaces
                continue;
            }

            pos = state.skipChars(pos, marker);

            // closing code fence must be at least as long as the opening one
            if (pos - mem < len) { continue; }

            // make sure tail has spaces only
            pos = state.skipSpaces(pos);

            if (pos < max) { continue; }

            haveEndMarker = true;

            // found!
            break;
        }

        // If a fence has heading spaces, they should be removed from its inner block
        len = state.tShift[startLine];

        state.line = nextLine + (haveEndMarker ? 1 : 0);
        
        var content = state.getLines(startLine + 1, nextLine, len, true)
                           .replace(/[ \n]+/g, ' ')
                           .trim();

        state.tokens.push({
            type: 'katex',
            params: params,
            content: content,
            lines: [startLine, state.line],
            level: state.level,
            block: true
        });

        return true;
    }
56281
function getFromDefine($line)
    {
        $line = "<?php $line"; // Trick the parser that we are in PHP file, instead of analyzing a single line

        $state = 0;
        $key = $value = '';

        $tokens = token_get_all($line);
        $token = reset($tokens);

        while ($token) {
            if (is_array($token)) {
                if ($token[0] == T_WHITESPACE || $token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
                    // do nothing
                } else {
                    if ($token[0] == T_STRING && strtolower($token[1]) == 'define') {
                        $state = 1;
                    } else {
                        if ($state == 2 && $this->isConstantToken($token[0])) {
                            $key = $token[1];
                            $state = 3;
                        } else {
                            if ($state == 4 && $this->isConstantToken($token[0])) {
                                $value = $token[1];
                                $state = 5;
                            }
                        }
                    }
                }
            } else {
                $symbol = trim($token);
                if ($symbol == '(' && $state == 1) {
                    $state = 2;
                } else {
                    if ($symbol == ',' && $state == 3) {
                        $state = 4;
                    } else {
                        if ($symbol == ')' && $state == 5) {
                            $state = 0;

                            yield [$this->stripQuotes($key), $this->getNativeValueFromDefinition($value)];
                        }
                    }
                }
            }
            $token = next($tokens);
        }
    }
1029244
protected function skipBulletListMarker(&$state, $startLine)
    {
        $pos = $state->bMarks[$startLine] + $state->tShift[$startLine];
        $max = $state->eMarks[$startLine];


        $marker = $state->src[$pos];
        $pos++;
        // Check bullet
        if ($marker !== '*' &&
            $marker !== '-' &&
            $marker !== '+') {
            return -1;
        }

        if ($pos < $max) {
            $ch = $state->src[$pos];

            if (!$state->md->utils->isSpace($ch)) {
                // " -test " - is not a list item
                return -1;
            }
        }

        return $pos;
    }
170018
static int countLineBreaks(String s) {
    int pos = -1;
    int count = 0;
    while (true) {
      int nextPos = s.indexOf('\n', pos + 1);
      if (nextPos == -1) {
        break;
      }
      pos = nextPos;
      count++;
    }
    return count;
  }
260955
private Result nextImpl(int pos, int inUnit) {
        int node=chars_.charAt(pos++);
        for(;;) {
            if(node<kMinLinearMatch) {
                return branchNext(pos, node, inUnit);
            } else if(node<kMinValueLead) {
                // Match the first of length+1 units.
                int length=node-kMinLinearMatch;  // Actual match length minus 1.
                if(inUnit==chars_.charAt(pos++)) {
                    remainingMatchLength_=--length;
                    pos_=pos;
                    return (length<0 && (node=chars_.charAt(pos))>=kMinValueLead) ?
                            valueResults_[node>>15] : Result.NO_VALUE;
                } else {
                    // No match.
                    break;
                }
            } else if((node&kValueIsFinal)!=0) {
                // No further matching units.
                break;
            } else {
                // Skip intermediate value.
                pos=skipNodeValue(pos, node);
                node&=kNodeTypeMask;
            }
        }
        stop();
        return Result.NO_MATCH;
    }
441437
function toggle(pos, state, ruleId) {
      var markers = ruleId ? scope[ruleId] : globals
      var currentState
      var previousState

      if (!markers) {
        markers = []
        scope[ruleId] = markers
      }

      previousState = getState(ruleId)
      currentState = state

      if (currentState !== previousState) {
        markers.push({state: currentState, position: pos})
      }

      /* Toggle all known rules. */
      if (!ruleId) {
        for (ruleId in scope) {
          toggle(pos, state, ruleId)
        }
      }
    }
1284609
public function pushState($state)
		{
		$r = array_push($this->states, $state);
		$this->state = $this->states[count($this->states) - 1];
		return $r;
		}
236566
protected static function _findPos($file, $callLine)
    {
        $len = strlen($file);
        $line = 1;
        $i = 0;

        while ($i < $len) {
            if ($file[$i] === "\n") {
                $line++;
            }
            if ($line === $callLine) {
                return $i;
            }
            $i++;
        }
    }
154931
protected function parseListLine($line)
    {
        $depth = 0;
        for ($i=0; $i<strlen($line); $i++) {
            $char = $line[$i];

            if ($char == ' ') {
                $depth++;
            } else if ($char == "\t") {
                $depth += 2;
            } else {
                break;
            }
        }

        if (preg_match('/^((\*|\-)|([\d#]+)\.) (.+)$/', trim($line), $match)) {
            return array(
                'prefix' => $line[$i],
                'ordered' => ($line[$i] == '*' || $line[$i] == '-') ? false : true,
                'depth' => $depth,
                'text' => array($match[4])
            );
        }

        return false;
    }
612109
protected function processContinuedLineInSameState($line)
    {
        switch ($this->state) {
            case 'msgctxt':
            case 'msgid':
            case 'msgid_plural':
                if (is_string($this->currentEntry[$this->state])) {
                    // Convert it to array
                    $this->currentEntry[$this->state] = array($this->currentEntry[$this->state]);
                }
                $this->currentEntry[$this->state][] = $line;
                break;
            case 'msgstr':
                $this->currentEntry['msgstr'][] = trim($line, '"');
                break;
            default:
                throw new \Exception('Parse error!');
        }
    }
251343
public static function setValidationState( $state = true)
	{
		$previousState = XBRL::$validating;
		XBRL::$validating = $state;
		return $previousState;
	}
118997
function tokenize(state, silent) {
	if (silent) {
		return false;
	}

	const start = state.pos;
	const max = state.posMax;
	let momChar = state.src.charAt(start);
	let nextChar = state.src.charAt(start + 1);

	// we're looking for two times the open symbol.
	if (momChar !== MARKER_OPEN || nextChar !== MARKER_OPEN) {
		return false;
	}

	// find the end sequence
	let end = -1;
	nextChar = state.src.charAt(start + 2);
	for (let i = start + 2; i < max && end === -1; i++) {
		momChar = nextChar;
		nextChar = state.src.charAt(i+1);
		if (momChar === MARKER_CLOSE && nextChar === MARKER_CLOSE) {
			// found the end!
			end = i;
		}
		if (momChar === MARKER_OPEN && momChar === MARKER_OPEN) {
			// found another opening sequence before the end. Thus, ignore ours!
			return false;
		}
		if (momChar === '\n') {
			// found end of line before the end sequence. Thus, ignore our start sequence!
			return false;
		}
	}

	// input ended before closing sequence
	if (end === -1) {
		return false;
	}

	// start tag
	state.push('kbd_open', TAG, 1);
	// parse inner
	state.pos += 2;
	state.posMax = end;
	state.md.inline.tokenize(state);
	state.pos = end + 2;
	state.posMax = max;
	// end tag
	state.push('kbd_close', TAG, -1);

	return true;
}