Beispiel #1
0
 /**
  * Parse next indented? text token.
  *
  * @return  TextToken
  */
 protected function parseTextBlock()
 {
     $node = new TextNode(null, $this->lexer->getCurrentLine());
     $this->expectTokenType('indent');
     while ($this->lexer->predictToken()->type === 'text' || $this->lexer->predictToken()->type === 'newline') {
         if ($this->lexer->predictToken()->type === 'newline') {
             $this->lexer->getAdvancedToken();
         } else {
             $node->addLine($this->lexer->getAdvancedToken()->value);
         }
     }
     $this->expectTokenType('outdent');
     return $node;
 }
Beispiel #2
0
 /**
  * Dump text node.
  *
  * @param   TextNode    $node   text node
  * @param   integer     $level  indentation level
  *
  * @return  string
  */
 protected function dumpText(TextNode $node, $level = 0)
 {
     $indent = str_repeat('  ', $level);
     return $indent . $this->replaceHolders(implode("\n" . $indent, $node->getLines()));
 }