You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
IsekaiMisc/BlockQuoteTagHandler.class.php

42 lines
1.2 KiB
PHTML

3 years ago
<?php
namespace Isekai;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
class BlockQuoteTagHandler extends ExtensionTagHandler {
public function sourceToDom(ParsoidExtensionAPI $extApi, string $src, array $extArgs): \DOMDocument {
$content = $extApi->extTagToDOM(
$extArgs,
'',
$src,
[
'wrapperTag' => 'span',
'parseOpts' => [
'extTag' => 'blockquote',
],
],
);
return $content;
}
public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) {
$wikiText = '';
foreach($dom->childNodes as $child){
if($child instanceof \DOMText){
/** @type \DOMText $child */
$wikiText .= $child->nodeValue;
} else {
$wikiText .= $extApi->domToWikitext([], $child);
}
}
return $wikiText;
}
public function domToWikitext(ParsoidExtensionAPI $extApi, \DOMElement $node, bool $wrapperUnmodified): string {
$innerCode = $this->getInnerWikitext($extApi, $node);
return "<span>\n{$innerCode}\n</span>";
}
}