JBBCode/Parser.php
protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer)
    {
        /* $parent's code definition doesn't allow its contents to be parsed. Here we use
         * a sliding window of three tokens until we find [ /tagname ], signifying the
         * end of the parent. */
        if (!$tokenizer->hasNext()) {
            return $parent;
        }
        $prevPrev = $tokenizer->next();
        if (!$tokenizer->hasNext()) {
            $this->createTextNode($parent, $prevPrev);
            return $parent;
        }
        $prev = $tokenizer->next();
        if (!$tokenizer->hasNext()) {
            $this->createTextNode($parent, $prevPrev);
            $this->createTextNode($parent, $prev);
            return $parent;
        }
        $curr = $tokenizer->next();
        while ('[' != $prevPrev || '/'.$parent->getTagName() != strtolower($prev) ||
            ']' != $curr) {
            $this->createTextNode($parent, $prevPrev);
            $prevPrev = $prev;
            $prev = $curr;
            if (!$tokenizer->hasNext()) {
                $this->createTextNode($parent, $prevPrev);
                $this->createTextNode($parent, $prev);
                return $parent;
            }
            $curr = $tokenizer->next();
        }
    }
protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer)
    {
        /* $parent's code definition doesn't allow its contents to be parsed. Here we use
         * a sliding window of three tokens until we find [ /tagname ], signifying the
         * end of the parent. */
        if (!$tokenizer->hasNext()) {
            return $parent;
        }
        $prevPrev = $tokenizer->next();
        if (!$tokenizer->hasNext()) {
            $this->createTextNode($parent, $prevPrev);
            return $parent;
        }
        $prev = $tokenizer->next();
        if (!$tokenizer->hasNext()) {
            $this->createTextNode($parent, $prevPrev);
            $this->createTextNode($parent, $prev);
            return $parent;
        }
        $curr = $tokenizer->next();
        while ('[' != $prevPrev || '/'.$parent->getTagName() != strtolower($prev) ||
            ']' != $curr) {
            $this->createTextNode($parent, $prevPrev);
            $prevPrev = $prev;
            $prev = $curr;
            if (!$tokenizer->hasNext()) {
                $this->createTextNode($parent, $prevPrev);
                $this->createTextNode($parent, $prev);
                return $parent;
            }
            $curr = $tokenizer->next();
        }
    }
protected function parseAsTextUntilClose ( ElementNode $ parent , Tokenizer $ tokenizer ) { /* $parent's code definition doesn't allow its contents to be parsed. Here we use
         * a sliding window of three tokens until we find [ /tagname ], signifying the
         * end of the parent. */ if ( ! $ tokenizer -> hasNext ( ) ) { return $ parent ; } $ prevPrev = $ tokenizer -> next ( ) ; if ( ! $ tokenizer -> hasNext ( ) ) { $ this -> createTextNode ( $ parent , $ prevPrev ) ; return $ parent ; } $ prev = $ tokenizer -> next ( ) ; if ( ! $ tokenizer -> hasNext ( ) ) { $ this -> createTextNode ( $ parent , $ prevPrev ) ; $ this -> createTextNode ( $ parent , $ prev ) ; return $ parent ; } $ curr = $ tokenizer -> next ( ) ; while ( '[' != $ prevPrev || '/' . $ parent -> getTagName ( ) != strtolower ( $ prev ) || ']' != $ curr ) { $ this -> createTextNode ( $ parent , $ prevPrev ) ; $ prevPrev = $ prev ; $ prev = $ curr ; if ( ! $ tokenizer -> hasNext ( ) ) { $ this -> createTextNode ( $ parent , $ prevPrev ) ; $ this -> createTextNode ( $ parent , $ prev ) ; return $ parent ; } $ curr = $ tokenizer -> next ( ) ; } }
Handles parsing elements whose CodeDefinitions disable parsing of element
contents. This function uses a rolling window of 3 tokens until it finds the
appropriate closing tag or reaches the end of the token stream.

@param ElementNode $parent  the current parent element
@param Tokenizer   $tokenizer  the tokenizer we're using

@return ElementNode the new parent element
Handles parsing elements whose CodeDefinitions disable parsing of element contents . This function uses a rolling window of 3 tokens until it finds the appropriate closing tag or reaches the end of the token stream .