]*>)(.*)()`s', $html, $match ); $html = "
$match[2]
"; } return $html; } /** * Write HTML to path * * @param string $relPath * @param Document $doc * @param string $origRelPath */ protected static function overwriteHtmlFile( string $relPath, Document $doc, string $origRelPath ): void { // Do not use $doc->saveHtml(), it outputs an awful soup of HTML entities for documents with // non-ASCII characters $html = file_get_contents( __DIR__ . '/../' . $origRelPath ); // Replace the body tag only in full Parsoid docs if ( strpos( $html, 'firstChild ); $html = preg_replace( '`(]*>)(.*)()`s', // Quote \ and $ in the replacement text '$1' . strtr( $innerHtml, [ '\\' => '\\\\', '$' => '\\$' ] ) . '$3', $html ); } else { $html = DOMCompat::getInnerHTML( DOMCompat::getBody( $doc ) ); } file_put_contents( __DIR__ . '/../' . $relPath, $html ); } /** * Create a comment parser * * @param Element $rootNode * @param array $data * @return CommentParser */ public static function createParser( Element $rootNode, array $data ): CommentParser { $services = MediaWikiServices::getInstance(); return new CommentParser( $rootNode, $services->getContentLanguage(), $services->getMainConfig(), $data ); } }