src/MarkdownIt/ParserInline.php
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;
    }
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;
    }
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 ; }
returns `true` if any rule reported success
@param StateInline $state
returns true if any rule reported success