Texy\BlockParser::next PHP Method

next() public method

if succesfull, increments current position and returns TRUE
public next ( $pattern, &$matches )
    public function next($pattern, &$matches)
    {
        if ($this->offset > strlen($this->text)) {
            return FALSE;
        }
        $matches = Regexp::match($this->text, $pattern . 'Am', Regexp::OFFSET_CAPTURE, $this->offset);
        if ($matches) {
            $this->offset += strlen($matches[0][0]) + 1;
            // 1 = "\n"
            foreach ($matches as $key => $value) {
                $matches[$key] = $value[0];
            }
            return TRUE;
        }
    }

Usage Example

コード例 #1
0
ファイル: BlockQuoteModule.php プロジェクト: chomenko/cemvin
 /**
  * Callback for:.
  *
  * > They went in single file, running like hounds on a strong scent,
  * and an eager light was in their eyes. Nearly due west the broad
  * swath of the marching Orcs tramped its ugly slot; the sweet grass
  * of Rohan had been bruised and blackened as they passed.
  * >:http://www.mycom.com/tolkien/twotowers.html
  *
  * @return Texy\HtmlElement|string|FALSE
  */
 public function pattern(Texy\BlockParser $parser, array $matches)
 {
     list(, $mMod, $mPrefix, $mContent) = $matches;
     // [1] => .(title)[class]{style}<>
     // [2] => spaces |
     // [3] => ... / LINK
     $texy = $this->texy;
     $el = new Texy\HtmlElement('blockquote');
     $mod = new Texy\Modifier($mMod);
     $mod->decorate($texy, $el);
     $content = '';
     $spaces = '';
     do {
         if ($mPrefix === ':') {
             $mod->cite = $texy->blockQuoteModule->citeLink($mContent);
             $content .= "\n";
         } else {
             if ($spaces === '') {
                 $spaces = max(1, strlen($mPrefix));
             }
             $content .= $mContent . "\n";
         }
         if (!$parser->next("#^>(?:|(\\ {1,{$spaces}}|:)(.*))()\$#mA", $matches)) {
             break;
         }
         /*
         			if ($mPrefix === '>') {
         				$content .= $mPrefix . $mContent . "\n";
         			} elseif ($mPrefix === ':') {
         				$mod->cite = $texy->blockQuoteModule->citeLink($mContent);
         				$content .= "\n";
         			} else {
         				if ($spaces === '') $spaces = max(1, strlen($mPrefix));
         				$content .= $mContent . "\n";
         			}
         			if (!$parser->next("#^\\>(?:(\\>|\\ {1,$spaces}|:)(.*))?()$#mA", $matches)) break;
         */
         list(, $mPrefix, $mContent) = $matches;
     } while (TRUE);
     $el->attrs['cite'] = $mod->cite;
     $el->parseBlock($texy, $content, $parser->isIndented());
     // no content?
     if (!$el->count()) {
         return FALSE;
     }
     // event listener
     $texy->invokeHandlers('afterBlockquote', [$parser, $el, $mod]);
     return $el;
 }
All Usage Examples Of Texy\BlockParser::next