mTokens = null; } /** * @param string $text * @return string */ public function getWrapped( $text ) { $this->mTokens = new ReplacementArray; $this->mMarkerIndex = 0; // Replace elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, array( &$this, 'replaceCallback' ), $text ); // ...and markers $wrappedtext = preg_replace_callback( '/\<\\/?mw:toc\>/', array( &$this, 'replaceCallback' ), $wrappedtext ); // ... and tags $wrappedtext = preg_replace_callback( '/\/s', array( &$this, 'replaceCallback' ), $wrappedtext ); // Modify inline Microdata and elements so they say and so // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config $wrappedtext = preg_replace( '!<(link|meta)([^>]*?)(/{0,1}>)!', '' . 'test' . $wrappedtext . ''; return $wrappedtext; } /** * @param array $m * * @return string */ public function replaceCallback( $m ) { $marker = Parser::MARKER_PREFIX . "-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX; $this->mMarkerIndex++; $this->mTokens->setPair( $marker, $m[0] ); return $marker; } /** * @param string $text * @return string */ public function postprocess( $text ) { // Revert back to <{link,meta}> $text = preg_replace( '!]*?)(/{0,1}>)!', '<$1$2$3', $text ); // Restore the contents of placeholder tokens $text = $this->mTokens->replace( $text ); return $text; } } ?>