diff --git a/src/Parsoid/Cite.php b/src/Parsoid/Cite.php index d2045952c..94198dad2 100644 --- a/src/Parsoid/Cite.php +++ b/src/Parsoid/Cite.php @@ -22,7 +22,10 @@ class Cite implements ExtensionModule { 'name' => 'ref', 'handler' => Ref::class, 'options' => [ - 'wt2html' => [ 'unpackOutput' => false ], + 'wt2html' => [ + 'unpackOutput' => false, + 'embedsHTMLInAttributes' => true + ], 'outputHasCoreMwDomSpecMarkup' => true ], ], @@ -30,6 +33,9 @@ class Cite implements ExtensionModule { 'name' => 'references', 'handler' => References::class, 'options' => [ + 'wt2html' => [ + 'embedsHTMLInAttributes' => true + ], 'html2wt' => [ 'format' => 'block' ], 'outputHasCoreMwDomSpecMarkup' => true ], diff --git a/src/Parsoid/Ref.php b/src/Parsoid/Ref.php index 8e36cd2f9..01c40b2af 100644 --- a/src/Parsoid/Ref.php +++ b/src/Parsoid/Ref.php @@ -3,6 +3,7 @@ declare( strict_types = 1 ); namespace Wikimedia\Parsoid\Ext\Cite; +use Closure; use Exception; use Wikimedia\Parsoid\DOM\DocumentFragment; use Wikimedia\Parsoid\DOM\Element; @@ -54,6 +55,16 @@ class Ref extends ExtensionTagHandler { ); } + /** @inheritDoc */ + public function processAttributeEmbeddedHTML( + ParsoidExtensionAPI $extApi, Element $elt, Closure $proc + ): void { + $dataMw = DOMDataUtils::getDataMw( $elt ); + if ( isset( $dataMw->body->html ) ) { + $dataMw->body->html = $proc( $dataMw->body->html ); + } + } + /** @inheritDoc */ public function lintHandler( ParsoidExtensionAPI $extApi, Element $ref, callable $defaultHandler diff --git a/src/Parsoid/References.php b/src/Parsoid/References.php index 28a2307e6..e39be4430 100644 --- a/src/Parsoid/References.php +++ b/src/Parsoid/References.php @@ -3,6 +3,7 @@ declare( strict_types = 1 ); namespace Wikimedia\Parsoid\Ext\Cite; +use Closure; use stdClass; use Wikimedia\Parsoid\Core\DomSourceRange; use Wikimedia\Parsoid\DOM\DocumentFragment; @@ -795,6 +796,16 @@ class References extends ExtensionTagHandler { return $domFragment; } + /** @inheritDoc */ + public function processAttributeEmbeddedHTML( + ParsoidExtensionAPI $extApi, Element $elt, Closure $proc + ): void { + $dataMw = DOMDataUtils::getDataMw( $elt ); + if ( isset( $dataMw->body->html ) ) { + $dataMw->body->html = $proc( $dataMw->body->html ); + } + } + /** @inheritDoc */ public function domToWikitext( ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified