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

These utilites pertain to querying / extracting / modifying wikitext information from the DOM. More...

Static Public Member Functions

static hasLiteralHTMLMarker (DataParsoid $dp)
 Check whether a node's data-parsoid object includes an indicator that the original wikitext was a literal HTML element (like table or p)
 
static isLiteralHTMLNode (?Node $node)
 Run a node through hasLiteralHTMLMarker.
 
static isZeroWidthWikitextElt (Node $node)
 
static isBlockNodeWithVisibleWT (Node $node)
 Is $node a block node that is also visible in wikitext? An example of an invisible block node is a <p>-tag that Parsoid generated, or a <ul>, <ol> tag.
 
static isATagFromWikiLinkSyntax (Element $node)
 Helper functions to detect when an A-$node uses [[..]]/[..]/... style syntax (for wikilinks, ext links, url links).
 
static isATagFromExtLinkSyntax (Element $node)
 Helper function to detect when an A-node uses ext-link syntax.
 
static isATagFromURLLinkSyntax (Element $node)
 Helper function to detect when an A-node uses url-link syntax.
 
static isATagFromMagicLinkSyntax (Element $node)
 Helper function to detect when an A-node uses magic-link syntax.
 
static matchTplType (Element $node)
 Check whether a node's typeof indicates that it is a template expansion.
 
static hasExpandedAttrsType (Element $node)
 Check whether a typeof indicates that it signifies an expanded attribute.
 
static isTplMarkerMeta (Node $node)
 Check whether a node is a meta tag that signifies a template expansion.
 
static isTplStartMarkerMeta (Node $node)
 Check whether a node is a meta signifying the start of a template expansion.
 
static isTplEndMarkerMeta (Node $node)
 Check whether a node is a meta signifying the end of a template expansion.
 
static isNewElt (Node $node)
 This tests whether a DOM node is a new node added during an edit session or an existing node from parsed wikitext.
 
static isIndentPre (Node $node)
 Check whether a pre is caused by indentation in the original wikitext.
 
static isInlineMedia (Node $node)
 
static isGeneratedFigure (Node $node)
 
static indentPreDSRCorrection (Node $textNode)
 Find how much offset is necessary for the DSR of an indent-originated pre tag.
 
static isEncapsulatedDOMForestRoot (Node $node)
 Check if $node is a root in an encapsulated DOM forest.
 
static isRedirectLink (?Node $node)
 Does $node represent a redirect link?
 
static isCategoryLink (?Node $node)
 Does $node represent a category link?
 
static isSolTransparentLink (?Node $node)
 Does $node represent a link that is sol-transparent?
 
static emitsSolTransparentSingleLineWT (Node $node)
 Check if '$node' emits wikitext that is sol-transparent in wikitext form.
 
static isFallbackIdSpan (Node $node)
 This is the span added to headings to add fallback ids for when legacy and HTML5 ids don't match up.
 
static isRenderingTransparentNode (Node $node)
 These are primarily 'metadata'-like $nodes that don't show up in output rendering.
 
static inHTMLTableTag (Node $node)
 Is $node nested inside a table tag that uses HTML instead of native wikitext?
 
static isFirstEncapsulationWrapperNode (Node $node)
 Is $node the first wrapper element of encapsulated content?
 
static isFirstExtensionWrapperNode (Node $node)
 Is $node the first wrapper element of extension content?
 
static isExtensionOutputtingCoreMwDomSpec (Node $node, Env $env)
 Checks whether a first encapsulation wrapper node is encapsulating an extension that outputs MediaWiki Core DOM Spec HTML (https://www.mediawiki.org/wiki/Specs/HTML)
 
static isEncapsulationWrapper (Node $node)
 Is $node an encapsulation wrapper elt?
 
static isDOMFragmentWrapper (Node $node)
 Is $node a DOMFragment wrapper?
 
static isSealedFragmentOfType (Node $node, string $type)
 Is $node a sealed DOMFragment of a specific type?
 
static isParsoidSectionTag (Node $node)
 Is $node a Parsoid-generated <section> tag?
 
static fromExtensionContent (Node $node, ?string $extType=null)
 Is the $node from extension content?
 
static fromEncapsulatedContent (Node $node)
 Is $node from encapsulated (template, extension, etc.) content?
 
static getWTSource (Frame $frame, Element $node)
 Compute, when possible, the wikitext source for a $node in an environment env.
 
static getAboutSiblings (Node $node, ?string $about)
 Gets all siblings that follow '$node' that have an 'about' as their about id.
 
static skipOverEncapsulatedContent (Node $node)
 This function is only intended to be used on encapsulated $nodes (Template/Extension/Param content).
 
static encodeComment (string $comment)
 Comment encoding/decoding.
 
static decodeComment (string $comment)
 Map an HTML DOM-escaped comment to a wikitext-escaped comment.
 
static decodedCommentLength ( $node)
 Utility function: we often need to know the wikitext DSR length for an HTML DOM comment value.
 
static getExtTagName (Node $node)
 
static getNativeExt (Env $env, Node $node)
 
static isIncludeTag (string $name)
 Is this an include directive?
 
static isAnnotationTag (Env $env, string $name)
 
static isAnnOrExtTag (Env $env, string $name)
 Check if tag is annotation or extension directive Adapted from similar grammar function.
 
static createEmptyLocalizationFragment (Document $doc)
 Creates a DocumentFragment containing a single span with type "mw:I18n".
 
static createPageContentI18nFragment (Document $doc, string $key, ?array $params=null)
 Creates an internationalization (i18n) message that will be localized into the page content language.
 
static createInterfaceI18nFragment (Document $doc, string $key, ?array $params=null)
 Creates an internationalization (i18n) message that will be localized into the user interface language.
 
static createLangI18nFragment (Document $doc, Bcp47Code $lang, string $key, ?array $params=null)
 Creates an internationalization (i18n) message that will be localized into an arbitrary language.
 
static addPageContentI18nAttribute (Element $element, string $name, string $key, ?array $params=null)
 Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the page content language.
 
static addInterfaceI18nAttribute (Element $element, string $name, string $key, ?array $params=null)
 Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the user interface language.
 
static addLangI18nAttribute (Element $element, Bcp47Code $lang, string $name, string $key, ?array $params=null)
 Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the provided language.
 
static matchAnnotationMeta (Node $node)
 Check whether a node is an annotation meta; if yes, returns its type.
 
static extractAnnotationType (Node $node, bool &$isStart=false)
 Extract the annotation type, excluding potential "/End" suffix; returns null if not a valid annotation meta.
 
static isAnnotationStartMarkerMeta (Node $node)
 Check whether a node is a meta signifying the start of an annotated part of the DOM.
 
static isAnnotationEndMarkerMeta (Node $node)
 Check whether a node is a meta signifying the end of an annotated part of the DOM.
 
static isMovedMetaTag (Node $node)
 Check whether the meta tag was moved from its initial position.
 
static isMarkerAnnotation (?Node $n)
 Returns true if a node is a (start or end) annotation meta tag.
 
static getMediaFormat (Element $node)
 Extracts the media format from the attribute string.
 
static hasVisibleCaption (Element $node)
 
static textContentFromCaption (Node $node)
 Ref dom post-processing happens after adding media info, so the linkbacks aren't available in the textContent added to the alt.
 

Public Attributes

const ANNOTATION_META_TYPE_REGEXP = '#^mw:(?:Annotation/([\w\d]+))(?:/End)?$#uD'
 Regexp for checking marker metas typeofs representing annotation markup.
 

Detailed Description

These utilites pertain to querying / extracting / modifying wikitext information from the DOM.

Note
Many of these methods are not safe to use unless the DOM has been loaded and prepared, as they consult DataParsoid from the NodeData.

Member Function Documentation

◆ addInterfaceI18nAttribute()

static Wikimedia\Parsoid\Utils\WTUtils::addInterfaceI18nAttribute ( Element $element,
string $name,
string $key,
?array $params = null )
static

Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the user interface language.

Parameters
Element$elementelement on which to add internationalization information
string$namename of the attribute whose value will be localized
string$keymessage key used for the attribute value localization
?array$paramsparameters for localization

◆ addLangI18nAttribute()

static Wikimedia\Parsoid\Utils\WTUtils::addLangI18nAttribute ( Element $element,
Bcp47Code $lang,
string $name,
string $key,
?array $params = null )
static

Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the provided language.

The use of this method is discouraged; ; use ::addPageContentI18nAttribute(...) and ::addInterfaceI18nAttribute(...) where possible rather than, respectively, ::addLangI18nAttribute(..., $wgContLang, ...) and ::addLangI18nAttribute(..., $wgLang, ...).

Parameters
Element$elementelement on which to add internationalization information
Bcp47Code$langlanguage in which the message will be localized
string$namename of the attribute whose value will be localized
string$keymessage key used for the attribute value localization
?array$paramsparameters for localization

◆ addPageContentI18nAttribute()

static Wikimedia\Parsoid\Utils\WTUtils::addPageContentI18nAttribute ( Element $element,
string $name,
string $key,
?array $params = null )
static

Adds to $element the internationalization information needed for the attribute $name to be localized in a later pass into the page content language.

Parameters
Element$elementelement on which to add internationalization information
string$namename of the attribute whose value will be localized
string$keymessage key used for the attribute value localization
?array$paramsparameters for localization

◆ createEmptyLocalizationFragment()

static Wikimedia\Parsoid\Utils\WTUtils::createEmptyLocalizationFragment ( Document $doc)
static

Creates a DocumentFragment containing a single span with type "mw:I18n".

The created span should be filled in with setDataNodeI18n to be valid.

Parameters
Document$doc
Returns
DocumentFragment
Exceptions
DOMException

◆ createInterfaceI18nFragment()

static Wikimedia\Parsoid\Utils\WTUtils::createInterfaceI18nFragment ( Document $doc,
string $key,
?array $params = null )
static

Creates an internationalization (i18n) message that will be localized into the user interface language.

The returned DocumentFragment contains, as a single child, a span element with the appropriate information for later localization.

Parameters
Document$doc
string$keymessage key for the message to be localized
?array$paramsparameters for localization
Returns
DocumentFragment
Exceptions
DOMException

◆ createLangI18nFragment()

static Wikimedia\Parsoid\Utils\WTUtils::createLangI18nFragment ( Document $doc,
Bcp47Code $lang,
string $key,
?array $params = null )
static

Creates an internationalization (i18n) message that will be localized into an arbitrary language.

The returned DocumentFragment contains, as a single child, a span element with the appropriate information for later localization. The use of this method is discouraged; use ::createPageContentI18nFragment(...) and ::createInterfaceI18nFragment(...) where possible rather than, respectively, ::createLangI18nFragment(..., $wgContLang, ...) and ::createLangI18nFragment(..., $wgLang,...).

Parameters
Document$doc
Bcp47Code$langlanguage for the localization
string$keymessage key for the message to be localized
?array$paramsparameters for localization
Returns
DocumentFragment
Exceptions
DOMException

◆ createPageContentI18nFragment()

static Wikimedia\Parsoid\Utils\WTUtils::createPageContentI18nFragment ( Document $doc,
string $key,
?array $params = null )
static

Creates an internationalization (i18n) message that will be localized into the page content language.

The returned DocumentFragment contains, as a single child, a span element with the appropriate information for later localization.

Parameters
Document$doc
string$keymessage key for the message to be localized
?array$paramsparameters for localization
Returns
DocumentFragment
Exceptions
DOMException

◆ decodeComment()

static Wikimedia\Parsoid\Utils\WTUtils::decodeComment ( string $comment)
static

Map an HTML DOM-escaped comment to a wikitext-escaped comment.

Parameters
string$commentDOM-escaped comment.
Returns
string Wikitext-escaped comment.

◆ decodedCommentLength()

static Wikimedia\Parsoid\Utils\WTUtils::decodedCommentLength ( $node)
static

Utility function: we often need to know the wikitext DSR length for an HTML DOM comment value.

Parameters
Comment | CommentTk$nodeA comment node containing a DOM-escaped comment.
Returns
int The wikitext length in UTF-8 bytes necessary to encode this comment, including 7 characters for the <!-- and --> delimiters.

◆ emitsSolTransparentSingleLineWT()

static Wikimedia\Parsoid\Utils\WTUtils::emitsSolTransparentSingleLineWT ( Node $node)
static

Check if '$node' emits wikitext that is sol-transparent in wikitext form.

This is a test for wikitext that doesn't introduce line breaks.

Comment, whitespace text $nodes, category links, redirect links, behavior switches, and include directives currently satisfy this definition.

This should come close to matching TokenUtils.isSolTransparent()

Parameters
Node$node
Returns
bool

◆ encodeComment()

static Wikimedia\Parsoid\Utils\WTUtils::encodeComment ( string $comment)
static

Comment encoding/decoding.

  • Some relevant phab tickets: T94055, T70146, T60184, T95039

The wikitext comment rule is very simple: ends a comment. This means we can have almost anything as the contents of a comment (except the string "-->", but see below), including several things that are not valid in HTML5 comments:

  • For one, the html5 comment parsing algorithm [0] leniently accepts –!> as a closing comment tag, which differs from the php+tidy combo.
  • If the comment's data matches /^-?>/, html5 will end the comment. For example, breaks up as (as text).
    • Finally, comment data shouldn't contain two consecutive hyphen-minus characters (–), nor end in a hyphen-minus character (/-$/) as defined in the spec [1].

We work around all these problems by using HTML entity encoding inside the comment body. The characters -, >, and & must be encoded in order to prevent premature termination of the comment by one of the cases above. Encoding other characters is optional; all entities will be decoded during wikitext serialization.

In order to allow arbitrary content inside a wikitext comment, including the forbidden string "-->" we also do some minimal entity decoding on the wikitext. We are also limited by our inability to encode DSR attributes on the comment $node, so our wikitext entity decoding must be 1-to-1: that is, there must be a unique "decoded" string for every wikitext sequence, and for every decoded string there must be a unique wikitext which creates it.

The basic idea here is to replace every string ab*c with the string with one more b in it. This creates a string with no instance of "ac", so you can use 'ac' to encode one more code point. In this case a is "--&", "b" is "amp;", and "c" is "gt;" and we use ac to encode "-->" (which is otherwise unspeakable in wikitext).

Note that any user content which does not match the regular expression /–(>|&(amp;)*gt;)/ is unchanged in its wikitext representation, as shown in the first two examples below.

User-authored comment text Wikitext HTML5 DOM


& - > & - > & &#43; > Use > here Use > here Use &gt; here --> –> &#43;&#43;> –> –&gt; &#43;&#43;&gt; –&gt; –&amp;gt; &#43;&#43;&amp;gt;

[0] http://www.w3.org/TR/html5/syntax.html#comment-start-state [1] http://www.w3.org/TR/html5/syntax.html#comments

Map a wikitext-escaped comment to an HTML DOM-escaped comment.

Parameters
string$commentWikitext-escaped comment.
Returns
string DOM-escaped comment.

◆ extractAnnotationType()

static Wikimedia\Parsoid\Utils\WTUtils::extractAnnotationType ( Node $node,
bool & $isStart = false )
static

Extract the annotation type, excluding potential "/End" suffix; returns null if not a valid annotation meta.

&$isStart is set to true if the annotation is a start tag, false otherwise.

Parameters
Node$node
bool&$isStart
Returns
?string The matched type, or null if no match.

◆ fromEncapsulatedContent()

static Wikimedia\Parsoid\Utils\WTUtils::fromEncapsulatedContent ( Node $node)
static

Is $node from encapsulated (template, extension, etc.) content?

Parameters
Node$node
Returns
bool

◆ fromExtensionContent()

static Wikimedia\Parsoid\Utils\WTUtils::fromExtensionContent ( Node $node,
?string $extType = null )
static

Is the $node from extension content?

Parameters
Node$node
?string$extTypeIf non-null, checks for that specific extension
Returns
bool

◆ getAboutSiblings()

static Wikimedia\Parsoid\Utils\WTUtils::getAboutSiblings ( Node $node,
?string $about )
static

Gets all siblings that follow '$node' that have an 'about' as their about id.

This is used to fetch transclusion/extension content by using the about-id as the key. This works because transclusion/extension content is a forest of dom-trees formed by adjacent dom-nodes. This is the contract that template encapsulation, dom-reuse, and VE code all have to abide by.

The only exception to this adjacency rule is IEW nodes in fosterable positions (in tables) which are not span-wrapped to prevent them from getting fostered out.

Parameters
Node$node
?string$about
Returns
Node[]

◆ getExtTagName()

static Wikimedia\Parsoid\Utils\WTUtils::getExtTagName ( Node $node)
static
Parameters
Node$node
Returns
?string

◆ getMediaFormat()

static Wikimedia\Parsoid\Utils\WTUtils::getMediaFormat ( Element $node)
static

Extracts the media format from the attribute string.

Parameters
Element$node
Returns
string

◆ getNativeExt()

static Wikimedia\Parsoid\Utils\WTUtils::getNativeExt ( Env $env,
Node $node )
static
Parameters
Env$env
Node$node
Returns
?ExtensionTagHandler

◆ getWTSource()

static Wikimedia\Parsoid\Utils\WTUtils::getWTSource ( Frame $frame,
Element $node )
static

Compute, when possible, the wikitext source for a $node in an environment env.

Returns null if the source cannot be extracted.

Parameters
Frame$frame
Element$node
Returns
string|null

◆ hasExpandedAttrsType()

static Wikimedia\Parsoid\Utils\WTUtils::hasExpandedAttrsType ( Element $node)
static

Check whether a typeof indicates that it signifies an expanded attribute.

Parameters
Element$node
Returns
bool

◆ hasLiteralHTMLMarker()

static Wikimedia\Parsoid\Utils\WTUtils::hasLiteralHTMLMarker ( DataParsoid $dp)
static

Check whether a node's data-parsoid object includes an indicator that the original wikitext was a literal HTML element (like table or p)

Parameters
DataParsoid$dp
Returns
bool

◆ hasVisibleCaption()

static Wikimedia\Parsoid\Utils\WTUtils::hasVisibleCaption ( Element $node)
static
Parameters
Element$node
Returns
bool

◆ indentPreDSRCorrection()

static Wikimedia\Parsoid\Utils\WTUtils::indentPreDSRCorrection ( Node $textNode)
static

Find how much offset is necessary for the DSR of an indent-originated pre tag.

Parameters
Node$textNode
Returns
int

◆ inHTMLTableTag()

static Wikimedia\Parsoid\Utils\WTUtils::inHTMLTableTag ( Node $node)
static

Is $node nested inside a table tag that uses HTML instead of native wikitext?

Parameters
Node$node
Returns
bool

◆ isAnnOrExtTag()

static Wikimedia\Parsoid\Utils\WTUtils::isAnnOrExtTag ( Env $env,
string $name )
static

Check if tag is annotation or extension directive Adapted from similar grammar function.

Parameters
Env$env
string$name
Returns
bool

◆ isAnnotationEndMarkerMeta()

static Wikimedia\Parsoid\Utils\WTUtils::isAnnotationEndMarkerMeta ( Node $node)
static

Check whether a node is a meta signifying the end of an annotated part of the DOM.

Parameters
Node$node
Returns
bool

◆ isAnnotationStartMarkerMeta()

static Wikimedia\Parsoid\Utils\WTUtils::isAnnotationStartMarkerMeta ( Node $node)
static

Check whether a node is a meta signifying the start of an annotated part of the DOM.

Parameters
Node$node
Returns
bool

◆ isATagFromExtLinkSyntax()

static Wikimedia\Parsoid\Utils\WTUtils::isATagFromExtLinkSyntax ( Element $node)
static

Helper function to detect when an A-node uses ext-link syntax.

rel attribute is not sufficient anymore since mw:ExtLink is used for multiple link types

Parameters
Element$node
Returns
bool

◆ isATagFromMagicLinkSyntax()

static Wikimedia\Parsoid\Utils\WTUtils::isATagFromMagicLinkSyntax ( Element $node)
static

Helper function to detect when an A-node uses magic-link syntax.

rel attribute is not sufficient anymore since mw:ExtLink is used for multiple link types

Parameters
Element$node
Returns
bool

◆ isATagFromURLLinkSyntax()

static Wikimedia\Parsoid\Utils\WTUtils::isATagFromURLLinkSyntax ( Element $node)
static

Helper function to detect when an A-node uses url-link syntax.

rel attribute is not sufficient anymore since mw:ExtLink is used for multiple link types

Parameters
Element$node
Returns
bool

◆ isATagFromWikiLinkSyntax()

static Wikimedia\Parsoid\Utils\WTUtils::isATagFromWikiLinkSyntax ( Element $node)
static

Helper functions to detect when an A-$node uses [[..]]/[..]/... style syntax (for wikilinks, ext links, url links).

rel-type is not sufficient anymore since mw:ExtLink is used for all the three link syntaxes.

Parameters
Element$node
Returns
bool

◆ isBlockNodeWithVisibleWT()

static Wikimedia\Parsoid\Utils\WTUtils::isBlockNodeWithVisibleWT ( Node $node)
static

Is $node a block node that is also visible in wikitext? An example of an invisible block node is a <p>-tag that Parsoid generated, or a <ul>, <ol> tag.

Parameters
Node$node
Returns
bool

◆ isDOMFragmentWrapper()

static Wikimedia\Parsoid\Utils\WTUtils::isDOMFragmentWrapper ( Node $node)
static

Is $node a DOMFragment wrapper?

Parameters
Node$node
Returns
bool

◆ isEncapsulatedDOMForestRoot()

static Wikimedia\Parsoid\Utils\WTUtils::isEncapsulatedDOMForestRoot ( Node $node)
static

Check if $node is a root in an encapsulated DOM forest.

Parameters
Node$node
Returns
bool

◆ isEncapsulationWrapper()

static Wikimedia\Parsoid\Utils\WTUtils::isEncapsulationWrapper ( Node $node)
static

Is $node an encapsulation wrapper elt?

All root-level $nodes of generated content are considered encapsulation wrappers and share an about-id.

Parameters
Node$node
Returns
bool

◆ isExtensionOutputtingCoreMwDomSpec()

static Wikimedia\Parsoid\Utils\WTUtils::isExtensionOutputtingCoreMwDomSpec ( Node $node,
Env $env )
static

Checks whether a first encapsulation wrapper node is encapsulating an extension that outputs MediaWiki Core DOM Spec HTML (https://www.mediawiki.org/wiki/Specs/HTML)

Parameters
Node$node
Env$env
Returns
bool

◆ isFallbackIdSpan()

static Wikimedia\Parsoid\Utils\WTUtils::isFallbackIdSpan ( Node $node)
static

This is the span added to headings to add fallback ids for when legacy and HTML5 ids don't match up.

This prevents broken links to legacy ids.

Parameters
Node$node
Returns
bool

◆ isFirstEncapsulationWrapperNode()

static Wikimedia\Parsoid\Utils\WTUtils::isFirstEncapsulationWrapperNode ( Node $node)
static

Is $node the first wrapper element of encapsulated content?

Parameters
Node$node
Returns
bool

◆ isFirstExtensionWrapperNode()

static Wikimedia\Parsoid\Utils\WTUtils::isFirstExtensionWrapperNode ( Node $node)
static

Is $node the first wrapper element of extension content?

Parameters
Node$node
Returns
bool

◆ isGeneratedFigure()

static Wikimedia\Parsoid\Utils\WTUtils::isGeneratedFigure ( Node $node)
static
Parameters
Node$node
Returns
bool

◆ isIncludeTag()

static Wikimedia\Parsoid\Utils\WTUtils::isIncludeTag ( string $name)
static

Is this an include directive?

Parameters
string$name
Returns
bool

◆ isIndentPre()

static Wikimedia\Parsoid\Utils\WTUtils::isIndentPre ( Node $node)
static

Check whether a pre is caused by indentation in the original wikitext.

Parameters
Node$node
Returns
bool

◆ isInlineMedia()

static Wikimedia\Parsoid\Utils\WTUtils::isInlineMedia ( Node $node)
static
Parameters
Node$node
Returns
bool

◆ isLiteralHTMLNode()

static Wikimedia\Parsoid\Utils\WTUtils::isLiteralHTMLNode ( ?Node $node)
static

Run a node through hasLiteralHTMLMarker.

Parameters
?Node$node
Returns
bool

◆ isMarkerAnnotation()

static Wikimedia\Parsoid\Utils\WTUtils::isMarkerAnnotation ( ?Node $n)
static

Returns true if a node is a (start or end) annotation meta tag.

Parameters
?Node$n
Returns
bool

◆ isMovedMetaTag()

static Wikimedia\Parsoid\Utils\WTUtils::isMovedMetaTag ( Node $node)
static

Check whether the meta tag was moved from its initial position.

Parameters
Node$node
Returns
bool

◆ isNewElt()

static Wikimedia\Parsoid\Utils\WTUtils::isNewElt ( Node $node)
static

This tests whether a DOM node is a new node added during an edit session or an existing node from parsed wikitext.

As written, this function can only be used on non-template/extension content or on the top-level nodes of template/extension content. This test will return the wrong results on non-top-level $nodes of template/extension content.

Parameters
Node$node
Returns
bool

◆ isParsoidSectionTag()

static Wikimedia\Parsoid\Utils\WTUtils::isParsoidSectionTag ( Node $node)
static

Is $node a Parsoid-generated <section> tag?

Parameters
Node$node
Returns
bool

◆ isRenderingTransparentNode()

static Wikimedia\Parsoid\Utils\WTUtils::isRenderingTransparentNode ( Node $node)
static

These are primarily 'metadata'-like $nodes that don't show up in output rendering.

  • In Parsoid output, they are represented by link/meta tags.
  • In the PHP parser, they are completely stripped from the input early on. Because of this property, these rendering-transparent $nodes are also SOL-transparent for the purposes of parsing behavior.
Parameters
Node$node
Returns
bool

◆ isSealedFragmentOfType()

static Wikimedia\Parsoid\Utils\WTUtils::isSealedFragmentOfType ( Node $node,
string $type )
static

Is $node a sealed DOMFragment of a specific type?

Parameters
Node$node
string$type
Returns
bool

◆ isTplEndMarkerMeta()

static Wikimedia\Parsoid\Utils\WTUtils::isTplEndMarkerMeta ( Node $node)
static

Check whether a node is a meta signifying the end of a template expansion.

Parameters
Node$node
Returns
bool

◆ isTplMarkerMeta()

static Wikimedia\Parsoid\Utils\WTUtils::isTplMarkerMeta ( Node $node)
static

Check whether a node is a meta tag that signifies a template expansion.

Parameters
Node$node
Returns
bool

◆ isTplStartMarkerMeta()

static Wikimedia\Parsoid\Utils\WTUtils::isTplStartMarkerMeta ( Node $node)
static

Check whether a node is a meta signifying the start of a template expansion.

Parameters
Node$node
Returns
bool

◆ isZeroWidthWikitextElt()

static Wikimedia\Parsoid\Utils\WTUtils::isZeroWidthWikitextElt ( Node $node)
static
Parameters
Node$node
Returns
bool

◆ matchAnnotationMeta()

static Wikimedia\Parsoid\Utils\WTUtils::matchAnnotationMeta ( Node $node)
static

Check whether a node is an annotation meta; if yes, returns its type.

Parameters
Node$node
Returns
?string

◆ matchTplType()

static Wikimedia\Parsoid\Utils\WTUtils::matchTplType ( Element $node)
static

Check whether a node's typeof indicates that it is a template expansion.

Parameters
Element$node
Returns
?string The matched type, or null if no match.

◆ skipOverEncapsulatedContent()

static Wikimedia\Parsoid\Utils\WTUtils::skipOverEncapsulatedContent ( Node $node)
static

This function is only intended to be used on encapsulated $nodes (Template/Extension/Param content).

Given a '$node' that has an about-id, it is assumed that it is generated by templates or extensions. This function skips over all following content nodes and returns the first non-template node that follows it.

Parameters
Node$node
Returns
Node|null

◆ textContentFromCaption()

static Wikimedia\Parsoid\Utils\WTUtils::textContentFromCaption ( Node $node)
static

Ref dom post-processing happens after adding media info, so the linkbacks aren't available in the textContent added to the alt.

However, when serializing, they are in the caption elements. So, this special handler drops the linkbacks for the purpose of comparison.

Parameters
Node$node
Returns
string

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