示例#1
0
 /**
  * Parses the end of a tag line (self-closing, content) and sets up the parser for the next line.
  */
 protected static function parse_end(nodes\Tag $node)
 {
     if ($node->content[0] == '<') {
         $node->content = substr($node->content, 1);
         $node->trim_inner = true;
     }
     if ($node->content[0] == '>') {
         $node->content = substr($node->content, 1);
         $node->trim_outer = true;
         $node->render_newline = false;
         if ($node->previous_sibling()) {
             $node->previous_sibling()->render_newline = false;
         }
     }
     if (in_array($node->tag_name, static::$parser->option('preserve'))) {
         $node->trim_inner = true;
     }
     if ($node->content[0] == '/') {
         if ($node->content != '/') {
             $node->exception('Parse error: self-closing tags cannot have content');
         }
         $node->content = substr($node->content, 1);
         $node->self_closing = true;
     }
     if ($node->content = trim($node->content)) {
         $text_node = new nodes\Text();
         $text_node->set_from_parser(static::$parser);
         $text_node->root = $node->root;
         $text_node->parent = $node;
         $text_node->indent_level = 0;
         $text_node->content = $node->content;
         Text::parse($text_node);
         $node->content = $text_node;
     }
     if ($node->self_closing or $node->content) {
         static::$parser->expect_indent(Parser::EXPECT_LESS | Parser::EXPECT_SAME);
     }
 }
示例#2
0
 /**
  * Handles the current line in the parser.
  */
 public static function handle()
 {
     $node = nodes\Text::new_from_parser(static::$parser);
     static::parse($node);
     static::$parser->expect_indent(Parser::EXPECT_LESS | Parser::EXPECT_SAME);
 }