RemexHtml/TreeBuilder/TreeBuilder.php
public function reconstructAFE( $sourceStart ) {
		$entry = $this->afe->getTail();
		// If there are no entries in the list of active formatting elements,
		// then there is nothing to reconstruct
		if ( !$entry ) {
			return;
		}
		// If the last is a marker, do nothing.
		if ( $entry instanceof Marker ) {
			return;
		}
		// Or if it is an open element, do nothing.
		if ( $entry->stackIndex !== null ) {
			return;
		}

		// Loop backward through the list until we find a marker or an
		// open element
		$foundIt = false;
		while ( $entry->prevAFE ) {
			$entry = $entry->prevAFE;
			if ( $entry instanceof Marker || $entry->stackIndex !== null ) {
				$foundIt = true;
				break;
			}
		}

		// Now loop forward, starting from the element after the current one (or
		// the first element if we didn't find a marker or open element),
		// recreating formatting elements and pushing them back onto the list
		// of open elements.
		if ( $foundIt ) {
			$entry = $entry->nextAFE;
		}
		do {
			$newElement = $this->insertForeign( HTMLData::NS_HTML, $entry->name,
				$entry->attrs, false, $sourceStart, 0 );
			$this->afe->replace( $entry, $newElement );
			$entry = $newElement->nextAFE;
		} while ( $entry );
	}
public function reconstructAFE( $sourceStart ) {
		$entry = $this->afe->getTail();
		// If there are no entries in the list of active formatting elements,
		// then there is nothing to reconstruct
		if ( !$entry ) {
			return;
		}
		// If the last is a marker, do nothing.
		if ( $entry instanceof Marker ) {
			return;
		}
		// Or if it is an open element, do nothing.
		if ( $entry->stackIndex !== null ) {
			return;
		}

		// Loop backward through the list until we find a marker or an
		// open element
		$foundIt = false;
		while ( $entry->prevAFE ) {
			$entry = $entry->prevAFE;
			if ( $entry instanceof Marker || $entry->stackIndex !== null ) {
				$foundIt = true;
				break;
			}
		}

		// Now loop forward, starting from the element after the current one (or
		// the first element if we didn't find a marker or open element),
		// recreating formatting elements and pushing them back onto the list
		// of open elements.
		if ( $foundIt ) {
			$entry = $entry->nextAFE;
		}
		do {
			$newElement = $this->insertForeign( HTMLData::NS_HTML, $entry->name,
				$entry->attrs, false, $sourceStart, 0 );
			$this->afe->replace( $entry, $newElement );
			$entry = $newElement->nextAFE;
		} while ( $entry );
	}
public function reconstructAFE ( $ sourceStart ) { $ entry = $ this -> afe -> getTail ( ) ; // If there are no entries in the list of active formatting elements, // then there is nothing to reconstruct if ( ! $ entry ) { return ; } // If the last is a marker, do nothing. if ( $ entry instanceof Marker ) { return ; } // Or if it is an open element, do nothing. if ( $ entry -> stackIndex !== null ) { return ; } // Loop backward through the list until we find a marker or an // open element $ foundIt = false ; while ( $ entry -> prevAFE ) { $ entry = $ entry -> prevAFE ; if ( $ entry instanceof Marker || $ entry -> stackIndex !== null ) { $ foundIt = true ; break ; } } // Now loop forward, starting from the element after the current one (or // the first element if we didn't find a marker or open element), // recreating formatting elements and pushing them back onto the list // of open elements. if ( $ foundIt ) { $ entry = $ entry -> nextAFE ; } do { $ newElement = $ this -> insertForeign ( HTMLData :: NS_HTML , $ entry -> name , $ entry -> attrs , false , $ sourceStart , 0 ) ; $ this -> afe -> replace ( $ entry , $ newElement ) ; $ entry = $ newElement -> nextAFE ; } while ( $ entry ) ; }
Reconstruct the active formatting elements.
@author C. Scott Ananian, Tim Starling
@param int $sourceStart
Reconstruct the active formatting elements .