69 list( $this->name, $this->rawChildren ) = $this->store[
$index];
87 if ( is_string( $descriptor ) ) {
88 $class = PPNode_Hash_Text::class;
89 } elseif ( is_array( $descriptor ) ) {
90 if ( $descriptor[self::NAME][0] ===
'@' ) {
91 $class = PPNode_Hash_Attr::class;
96 throw new MWException( __METHOD__ .
': invalid node descriptor' );
108 for ( $node = $this->
getFirstChild(); $node; $node = $node->getNextSibling() ) {
110 $attribs .=
' ' . $node->name .
'="' . htmlspecialchars( $node->value ) .
'"';
112 $inner .= $node->__toString();
115 if ( $inner ===
'' ) {
116 return "<{$this->name}$attribs/>";
118 return "<{$this->name}$attribs>$inner</{$this->name}>";
127 foreach ( $this->rawChildren as $i => $child ) {
141 if ( !isset( $this->rawChildren[0] ) ) {
167 foreach ( $this->rawChildren as $i => $child ) {
168 if ( is_array( $child ) && $child[self::NAME] ===
$name ) {
225 foreach ( $children as $i => $child ) {
226 if ( !is_array( $child ) ) {
229 if ( $child[self::NAME] ===
'name' ) {
230 $bits[
'name'] =
new self( $children, $i );
231 if ( isset( $child[self::CHILDREN][0][self::NAME] )
236 } elseif ( $child[self::NAME] ===
'value' ) {
237 $bits[
'value'] =
new self( $children, $i );
241 if ( !isset( $bits[
'name'] ) ) {
242 throw new MWException(
'Invalid brace node passed to ' . __METHOD__ );
244 if ( !isset( $bits[
'index'] ) ) {
268 foreach ( $children as $i => $child ) {
269 if ( !is_array( $child ) ) {
272 switch ( $child[self::NAME] ) {
274 $bits[
'name'] =
new self( $children, $i );
277 $bits[
'attr'] =
new self( $children, $i );
280 $bits[
'inner'] =
new self( $children, $i );
283 $bits[
'close'] =
new self( $children, $i );
287 if ( !isset( $bits[
'name'] ) ) {
288 throw new MWException(
'Invalid ext node passed to ' . __METHOD__ );
300 if ( $this->name !==
'h' ) {
301 throw new MWException(
'Invalid h node passed to ' . __METHOD__ );
313 foreach ( $children as $i => $child ) {
314 if ( !is_array( $child ) ) {
317 if ( $child[self::NAME] ===
'@i' ) {
319 } elseif ( $child[self::NAME] ===
'@level' ) {
323 if ( !isset( $bits[
'i'] ) ) {
324 throw new MWException(
'Invalid h node passed to ' . __METHOD__ );
346 $bits = [
'lineStart' =>
'' ];
347 foreach ( $children as $i => $child ) {
348 if ( !is_array( $child ) ) {
351 switch ( $child[self::NAME] ) {
353 $bits[
'title'] =
new self( $children, $i );
356 $parts[] =
new self( $children, $i );
359 $bits[
'lineStart'] =
'1';
363 if ( !isset( $bits[
'title'] ) ) {
364 throw new MWException(
'Invalid node passed to ' . __METHOD__ );