/**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @param array $name
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token, array $name)
 {
     // Perhaps check, that only node of type section and metadata are
     // added.
     parent::__construct($token, self::NAMED_REFERENCE);
     $this->name = $name;
 }
Exemple #2
0
 /**
  * Construct RST document node
  * 
  * @param ezcDocumentRstToken $token 
  * @param array $name 
  * @param int $footnoteType 
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token, array $name, $footnoteType = self::NUMBERED)
 {
     // Perhaps check, that only node of type section and metadata are
     // added.
     parent::__construct($token, self::FOOTNOTE);
     $this->name = $name;
     $this->footnoteType = $footnoteType;
 }
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token)
 {
     // Perhaps check, that only node of type section and metadata are
     // added.
     parent::__construct($token, self::ENUMERATED_LIST_LIST);
 }
Exemple #4
0
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token)
 {
     parent::__construct($token, self::TARGET);
 }
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token)
 {
     // Perhaps check, that only node of type section and metadata are
     // added.
     parent::__construct($token, self::ANON_REFERENCE);
 }
Exemple #6
0
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token)
 {
     parent::__construct($token, self::TRANSITION);
 }
Exemple #7
0
 /**
  * Reduce prior sections, if a new section has been found.
  *
  * If a new section has been found all sections with a higher depth level
  * can be closed, and all items fitting into sections may be aggregated by
  * the respective sections as well.
  *
  * @param ezcDocumentRstNode $node
  * @return void
  */
 protected function reduceSection(ezcDocumentRstNode $node)
 {
     // Collected node for prior section
     $collected = array();
     $lastSectionDepth = -1;
     // Include all paragraphs, tables, lists and sections with a higher
     // nesting depth
     while ($child = $this->documentStack->shift()) {
         /* DEBUG
            echo "  -> Try node: " . ezcDocumentRstNode::getTokenName( $child->type ) . ".\n";
            // /DEBUG */
         if (!in_array($child->type, $this->blockNodes, true)) {
             $this->triggerError(E_PARSE, "Unexpected node: " . ezcDocumentRstNode::getTokenName($child->type) . ".", null, $child->token->line, $child->token->position);
         }
         if ($child->type === ezcDocumentRstNode::SECTION) {
             if ($child->depth <= $node->depth && $node->depth !== 0) {
                 // If the found section has a same or higher level, just
                 // put everything back on the stack
                 $child->nodes = array_merge($child->nodes, $collected);
                 $this->documentStack->unshift($child);
                 /* DEBUG
                    echo "   -> Leave on stack.\n";
                    $this->dumpStack();
                    // /DEBUG */
                 return $node;
             }
             // Reduce document, if reached
             if ($child->depth == 0 && $node->depth == 0) {
                 /* DEBUG
                    echo "   -> Aggregate in root document node.\n";
                    // /DEBUG */
                 $child->nodes = array_merge($child->nodes, $collected);
                 return $child;
             }
             // Check for title depth incosistency
             if ($lastSectionDepth - $child->depth > 1) {
                 $this->triggerError(E_PARSE, "Title depth inconsitency.", null, $child->token->line, $child->token->position);
             }
             if ($lastSectionDepth === -1 || $lastSectionDepth > $child->depth) {
                 // If the section level is higher then in our new node and
                 // lower the the last node, reduce sections.
                 /* DEBUG
                    echo "   -> Reduce section {$child->depth}.\n";
                    // /DEBUG */
                 $child->nodes = array_merge($child->nodes, $collected);
                 $collected = array();
             }
             // Sections on an equal level are just appended, for all
             // sections we remember the last depth.
             $lastSectionDepth = $child->depth;
         }
         /* DEBUG
            echo "  -> Found another child...\n";
            // /DEBUG */
         array_unshift($collected, $child);
     }
     // No reduction found, put things back on stack.
     /* DEBUG
        echo "   -> Put everything back on stack.\n";
        // /DEBUG */
     $this->documentStack->prepend(array_reverse($collected));
     return $node;
 }
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token)
 {
     parent::__construct($token, self::MARKUP_LITERAL);
 }
Exemple #9
0
 /**
  * Construct RST document node
  *
  * @param ezcDocumentRstToken $token
  * @param ezcDocumentRstTitleNode $title
  * @param int $depth
  * @return void
  */
 public function __construct(ezcDocumentRstToken $token, ezcDocumentRstTitleNode $title = null, $depth = 0)
 {
     parent::__construct($token, self::SECTION);
     $this->title = $title;
     $this->depth = $depth;
 }