mTokens = []; $this->mMarkerIndex = 0; // Replace elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, [ $this, 'replaceCallback' ], $text ); // ...and markers $wrappedtext = preg_replace_callback( '/\<\\/?mw:toc\>/', [ $this, 'replaceCallback' ], $wrappedtext ); // ... and tags $wrappedtext = preg_replace_callback( '/\/s', [ $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}>)!', '([ \r\n\t\f]*)!", '
  • \1
  • ', $wrappedtext ); // Wrap the whole thing in a doctype and body for Tidy. $wrappedtext = '' . 'test' . $wrappedtext . ''; return $wrappedtext; } /** * @param array $m * @return string */ private function replaceCallback( array $m ) { $marker = Parser::MARKER_PREFIX . "-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX; $this->mMarkerIndex++; $this->mTokens[$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 ); // Remove datafld $text = str_replace( '
  • mTokens ); return $text; } }