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

Some diff marker aware DOM utils. More...

Static Public Member Functions

static hasNChildren (Node $node, int $nchildren, bool $countDiffMarkers=false)
 Test the number of children this node has without using DOMNode::$childNodes->count().
 
static isContentNode (?Node $node)
 Is a node a content node?
 
static firstNonSepChild (Node $node)
 Get the first child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.
 
static lastNonSepChild (Node $node)
 Get the last child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.
 
static previousNonSepSibling (Node $node)
 Get the previous non separator sibling node.
 
static nextNonSepSibling (Node $node)
 Get the next non separator sibling node.
 
static numNonDeletedChildNodes (Node $node)
 Return the numbler of non deleted child nodes.
 
static firstNonDeletedChild (Node $node)
 Get the first non-deleted child of node.
 
static lastNonDeletedChild (Node $node)
 Get the last non-deleted child of node.
 
static nextNonDeletedSibling (Node $node)
 Get the next non deleted sibling.
 
static previousNonDeletedSibling (Node $node)
 Get the previous non deleted sibling.
 
static nodeEssentiallyEmpty (Node $node, bool $strict=false)
 Does node contain nothing or just non-newline whitespace? strict adds the condition that all whitespace is forbidden.
 

Detailed Description

Some diff marker aware DOM utils.

Member Function Documentation

◆ firstNonDeletedChild()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::firstNonDeletedChild ( Node $node)
static

Get the first non-deleted child of node.

Parameters
Node$node
Returns
Node|null

◆ firstNonSepChild()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::firstNonSepChild ( Node $node)
static

Get the first child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.

Parameters
Node$node
Returns
Node|null

◆ hasNChildren()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::hasNChildren ( Node $node,
int $nchildren,
bool $countDiffMarkers = false )
static

Test the number of children this node has without using DOMNode::$childNodes->count().

This walks the sibling list and so takes O(nchildren) time – so nchildren is expected to be small (say: 0, 1, or 2).

Skips all diff markers by default.

Parameters
Node$node
int$nchildren
bool$countDiffMarkers
Returns
bool

◆ isContentNode()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::isContentNode ( ?Node $node)
static

Is a node a content node?

Parameters
?Node$node
Returns
bool

◆ lastNonDeletedChild()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::lastNonDeletedChild ( Node $node)
static

Get the last non-deleted child of node.

Parameters
Node$node
Returns
Node|null

◆ lastNonSepChild()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::lastNonSepChild ( Node $node)
static

Get the last child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.

Parameters
Node$node
Returns
Node|null

◆ nextNonDeletedSibling()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::nextNonDeletedSibling ( Node $node)
static

Get the next non deleted sibling.

Parameters
Node$node
Returns
Node|null

◆ nextNonSepSibling()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::nextNonSepSibling ( Node $node)
static

Get the next non separator sibling node.

Parameters
Node$node
Returns
Node|null

◆ nodeEssentiallyEmpty()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::nodeEssentiallyEmpty ( Node $node,
bool $strict = false )
static

Does node contain nothing or just non-newline whitespace? strict adds the condition that all whitespace is forbidden.

Parameters
Node$node
bool$strict
Returns
bool

◆ numNonDeletedChildNodes()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::numNonDeletedChildNodes ( Node $node)
static

Return the numbler of non deleted child nodes.

Parameters
Node$node
Returns
int

◆ previousNonDeletedSibling()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::previousNonDeletedSibling ( Node $node)
static

Get the previous non deleted sibling.

Parameters
Node$node
Returns
Node|null

◆ previousNonSepSibling()

static Wikimedia\Parsoid\Utils\DiffDOMUtils::previousNonSepSibling ( Node $node)
static

Get the previous non separator sibling node.

Parameters
Node$node
Returns
Node|null

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