MediaWiki master
MediaWiki\Html\HtmlHelper Class Reference

Static utilities for manipulating HTML strings. More...

Static Public Member Functions

static modifyElements (string $htmlFragment, callable $shouldModifyCallback, callable $modifyCallback, bool $html5format=true)
 Modify elements of an HTML fragment via a user-provided callback.
 

Detailed Description

Static utilities for manipulating HTML strings.

Definition at line 16 of file HtmlHelper.php.

Member Function Documentation

◆ modifyElements()

static MediaWiki\Html\HtmlHelper::modifyElements ( string $htmlFragment,
callable $shouldModifyCallback,
callable $modifyCallback,
bool $html5format = true )
static

Modify elements of an HTML fragment via a user-provided callback.

Parameters
string$htmlFragmentHTML fragment. Must be valid (ie. coming from the parser, not the user).
callable$shouldModifyCallbackA callback which takes a single RemexHtml\Serializer\SerializerNode argument, and returns true if it should be modified.
callable$modifyCallbackA callback which takes a single RemexHtml\Serializer\SerializerNode argument and actually performs the modification on it. It must return the new node (which can be the original node object).
bool$html5formatDefaults to true, which uses standard HTML5 serialization for the parsed HTML. If set to false, uses a serialization which is more compatible with the output of the legacy parser; see RemexCompatFormatter for more details. When false, attributes and text nodes contain unexpanded character references (entities).
Returns
string

Definition at line 34 of file HtmlHelper.php.

References MediaWiki\Html\HtmlHelperTrait.


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