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.

39 lines
1.1 KiB
PHP

<?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) {
return $extApi->extTagToDOM(
$extArgs,
'',
$src,
[
'wrapperTag' => 'span',
'parseOpts' => [
'extTag' => 'blockquote',
],
],
);
}
public function getInnerWikitext(ParsoidExtensionAPI $extApi, \DOMElement $dom) {
$wikiText = '';
foreach($dom->childNodes as $child){
if($child instanceof \DOMText){
$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>";
}
}