Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\ParserTests\ParserHook Class Reference

See tests/parser/ParserTestParserHook.php in core. More...

+ Inheritance diagram for Wikimedia\Parsoid\ParserTests\ParserHook:
+ Collaboration diagram for Wikimedia\Parsoid\ParserTests\ParserHook:

Public Member Functions

 sourceToDom (ParsoidExtensionAPI $extApi, string $content, array $args)
 Convert an extension tag's content to "prepared and loaded" DOM.
Parameters
ParsoidExtensionAPI$extApi
string$srcExtension tag content
array$extArgsExtension tag arguments The extension tag arguments should be treated as opaque objects and any necessary inspection should be handled through the API.
Returns
DocumentFragment|false|null DocumentFragment if returning some parsed content false to fallback to the default handler for the content null to drop the instance completely

 
 processAttributeEmbeddedDom (ParsoidExtensionAPI $extApi, Element $elt, callable $proc)
 Extensions might embed HTML in attributes in their own custom representation (whether in data-mw or elsewhere).Core Parsoid will need a way to traverse such content. This method is a way for extension tag handlers to provide this functionality. Parsoid will only call this method if the tag's config sets the options['wt2html']['embedsDomInAttributes'] property to true.Override this method if your element embeds content directly as a DocumentFragment, which is recommended. If your element embeds content as a serialized HTML string, then processAttributeEmbeddedHTML() may be more convenient.
Parameters
ParsoidExtensionAPI$extApi
Element$eltThe node whose data attributes need to be examined
callable(DocumentFragment):bool$proc The processor that will process the embedded HTML. This processor will be provided a DocumentFragment and is expected to return true if that fragment was modified.

 
 domToWikitext (ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified)
 Serialize a DOM node created by this extension to wikitext.
Parameters
ParsoidExtensionAPI$extApi
Element$nodeA node in a "prepared and loaded" document.
bool$wrapperUnmodified
Returns
string|false Return false to use the default serialization.

 
 getConfig ()
 Return information about this extension module.The structure of the return value is enforced by moduleconfig.schema.json, in this directory.
See also
https://www.mediawiki.org/wiki/Parsoid/Internals/Module_Configuration_Schema
Returns
array{name:string}

 
- Public Member Functions inherited from Wikimedia\Parsoid\Ext\ExtensionTagHandler
 processAttributeEmbeddedHTML (ParsoidExtensionAPI $extApi, Element $elt, Closure $proc)
 Extensions might embed HTML in attributes in their own custom representation (whether in data-mw or elsewhere).
 
 lintHandler (ParsoidExtensionAPI $extApi, Element $rootNode, callable $defaultHandler)
 Lint handler for this extension.
 
 diffHandler (ParsoidExtensionAPI $extApi, callable $domDiff, Element $origNode, Element $editedNode)
 XXX: Experimental.
 

Static Public Member Functions

static getParserTestConfigFileName ()
 Ensure that both integrated and standalone test runners have the magic word definitions used by these test hooks.
 

Detailed Description

See tests/parser/ParserTestParserHook.php in core.

Member Function Documentation

◆ domToWikitext()

Wikimedia\Parsoid\ParserTests\ParserHook::domToWikitext ( ParsoidExtensionAPI $extApi,
Element $node,
bool $wrapperUnmodified )

Serialize a DOM node created by this extension to wikitext.

Parameters
ParsoidExtensionAPI$extApi
Element$nodeA node in a "prepared and loaded" document.
bool$wrapperUnmodified
Returns
string|false Return false to use the default serialization.

Reimplemented from Wikimedia\Parsoid\Ext\ExtensionTagHandler.

◆ getConfig()

Wikimedia\Parsoid\ParserTests\ParserHook::getConfig ( )

Return information about this extension module.The structure of the return value is enforced by moduleconfig.schema.json, in this directory.

See also
https://www.mediawiki.org/wiki/Parsoid/Internals/Module_Configuration_Schema
Returns
array{name:string}

Implements Wikimedia\Parsoid\Ext\ExtensionModule.

◆ getParserTestConfigFileName()

static Wikimedia\Parsoid\ParserTests\ParserHook::getParserTestConfigFileName ( )
static

Ensure that both integrated and standalone test runners have the magic word definitions used by these test hooks.

See also
SiteConfig::getCustomSiteConfigFileName()
ParserTestRunner::staticSetup() (in core)

◆ processAttributeEmbeddedDom()

Wikimedia\Parsoid\ParserTests\ParserHook::processAttributeEmbeddedDom ( ParsoidExtensionAPI $extApi,
Element $elt,
callable $proc )

Extensions might embed HTML in attributes in their own custom representation (whether in data-mw or elsewhere).Core Parsoid will need a way to traverse such content. This method is a way for extension tag handlers to provide this functionality. Parsoid will only call this method if the tag's config sets the options['wt2html']['embedsDomInAttributes'] property to true.Override this method if your element embeds content directly as a DocumentFragment, which is recommended. If your element embeds content as a serialized HTML string, then processAttributeEmbeddedHTML() may be more convenient.

Parameters
ParsoidExtensionAPI$extApi
Element$eltThe node whose data attributes need to be examined
callable(DocumentFragment):bool$proc The processor that will process the embedded HTML. This processor will be provided a DocumentFragment and is expected to return true if that fragment was modified.

Reimplemented from Wikimedia\Parsoid\Ext\ExtensionTagHandler.

◆ sourceToDom()

Wikimedia\Parsoid\ParserTests\ParserHook::sourceToDom ( ParsoidExtensionAPI $extApi,
string $content,
array $args )

Convert an extension tag's content to "prepared and loaded" DOM.

Parameters
ParsoidExtensionAPI$extApi
string$srcExtension tag content
array$extArgsExtension tag arguments The extension tag arguments should be treated as opaque objects and any necessary inspection should be handled through the API.
Returns
DocumentFragment|false|null DocumentFragment if returning some parsed content false to fallback to the default handler for the content null to drop the instance completely

Reimplemented from Wikimedia\Parsoid\Ext\ExtensionTagHandler.


The documentation for this class was generated from the following file: