isIndented() public method

public isIndented ( )
Exemplo n.º 1
0
 /**
  * @return void
  */
 public function process(Texy\BlockParser $parser, $content, Texy\HtmlElement $el)
 {
     if ($parser->isIndented()) {
         $parts = preg_split('#(\\n(?! )|\\n{2,})#', $content, -1, PREG_SPLIT_NO_EMPTY);
     } else {
         $parts = preg_split('#(\\n{2,})#', $content, -1, PREG_SPLIT_NO_EMPTY);
     }
     foreach ($parts as $s) {
         $s = trim($s);
         if ($s === '') {
             continue;
         }
         // try to find modifier
         $mod = NULL;
         if ($mx = Regexp::match($s, '#' . Texy\Patterns::MODIFIER_H . '(?=\\n|\\z)#sUm', Regexp::OFFSET_CAPTURE)) {
             list($mMod) = $mx[1];
             $s = trim(substr_replace($s, '', $mx[0][1], strlen($mx[0][0])));
             if ($s === '') {
                 continue;
             }
             $mod = new Texy\Modifier();
             $mod->setProperties($mMod);
         }
         $res = $this->texy->invokeAroundHandlers('paragraph', $parser, [$s, $mod]);
         if ($res) {
             $el->insert(NULL, $res);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
 }