mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 01:30:32 +00:00
ParsoidExtensionAPI: Add method to process HTML embedded in attributes
* Parsoid core cannot know anything about how extensions represent information in their DOM. We were missing an extension API method and config that lets extensions specify this information along with handlers to process embedded content. * This patch fills that above gap. * There is a FIXME in ContentUtils::shiftDSR which will be addressed in followup patches with this new functionality. Change-Id: If921ca471f25f21671a60c3f796fdf145267364d
This commit is contained in:
parent
1e61376d59
commit
5a77aa959b
|
@ -22,7 +22,10 @@ class Cite implements ExtensionModule {
|
||||||
'name' => 'ref',
|
'name' => 'ref',
|
||||||
'handler' => Ref::class,
|
'handler' => Ref::class,
|
||||||
'options' => [
|
'options' => [
|
||||||
'wt2html' => [ 'unpackOutput' => false ],
|
'wt2html' => [
|
||||||
|
'unpackOutput' => false,
|
||||||
|
'embedsHTMLInAttributes' => true
|
||||||
|
],
|
||||||
'outputHasCoreMwDomSpecMarkup' => true
|
'outputHasCoreMwDomSpecMarkup' => true
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -30,6 +33,9 @@ class Cite implements ExtensionModule {
|
||||||
'name' => 'references',
|
'name' => 'references',
|
||||||
'handler' => References::class,
|
'handler' => References::class,
|
||||||
'options' => [
|
'options' => [
|
||||||
|
'wt2html' => [
|
||||||
|
'embedsHTMLInAttributes' => true
|
||||||
|
],
|
||||||
'html2wt' => [ 'format' => 'block' ],
|
'html2wt' => [ 'format' => 'block' ],
|
||||||
'outputHasCoreMwDomSpecMarkup' => true
|
'outputHasCoreMwDomSpecMarkup' => true
|
||||||
],
|
],
|
||||||
|
|
|
@ -3,6 +3,7 @@ declare( strict_types = 1 );
|
||||||
|
|
||||||
namespace Wikimedia\Parsoid\Ext\Cite;
|
namespace Wikimedia\Parsoid\Ext\Cite;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Wikimedia\Parsoid\DOM\DocumentFragment;
|
use Wikimedia\Parsoid\DOM\DocumentFragment;
|
||||||
use Wikimedia\Parsoid\DOM\Element;
|
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 */
|
/** @inheritDoc */
|
||||||
public function lintHandler(
|
public function lintHandler(
|
||||||
ParsoidExtensionAPI $extApi, Element $ref, callable $defaultHandler
|
ParsoidExtensionAPI $extApi, Element $ref, callable $defaultHandler
|
||||||
|
|
|
@ -3,6 +3,7 @@ declare( strict_types = 1 );
|
||||||
|
|
||||||
namespace Wikimedia\Parsoid\Ext\Cite;
|
namespace Wikimedia\Parsoid\Ext\Cite;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use Wikimedia\Parsoid\Core\DomSourceRange;
|
use Wikimedia\Parsoid\Core\DomSourceRange;
|
||||||
use Wikimedia\Parsoid\DOM\DocumentFragment;
|
use Wikimedia\Parsoid\DOM\DocumentFragment;
|
||||||
|
@ -795,6 +796,16 @@ class References extends ExtensionTagHandler {
|
||||||
return $domFragment;
|
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 */
|
/** @inheritDoc */
|
||||||
public function domToWikitext(
|
public function domToWikitext(
|
||||||
ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified
|
ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified
|
||||||
|
|
Loading…
Reference in a new issue