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

DOM normalization. More...

Public Member Functions

 __construct (SerializerState $state)
 
 addDiffMarks (Node $node, string $mark, bool $dontRecurse=false)
 
 merge (Element $a, Element $b)
 Transfer all of b's children to a and delete b.
 
 swap (Element $a, Element $b)
 b is a's sole non-deleted child.
 
 hoistLinks (Element $node, bool $rtl)
 
 stripIfEmpty (Element $node)
 
 moveTrailingSpacesOut (Node $node)
 
 stripBRs (Element $node)
 
 stripBidiCharsAroundCategories (Node $node)
 FIXME see https://gerrit.wikimedia.org/r/#/c/mediawiki/services/parsoid/+/500975/7/src/Html2Wt/DOMNormalizer.php@423.
 
 moveFormatTagOutsideATag (Element $node)
 When an A tag is encountered, if there are format tags inside, move them outside Also merge a single sibling A tag that is mergable The link href and text must match for this normalization to take effect.
 
 normalizeNode (Node $node)
 Wikitext normalizations implemented right now:
 
 normalizeSiblingPair (Node $a, Node $b)
 
 processSubtree (Node $node, bool $recurse)
 
 processNode (Node $node, bool $recurse)
 
 normalize (Node $node)
 

Detailed Description

DOM normalization.

DOM normalizations are performed after DOMDiff is run. So, normalization routines should update diff markers appropriately.

Member Function Documentation

◆ merge()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::merge ( Element $a,
Element $b )

Transfer all of b's children to a and delete b.

Parameters
Element$a
Element$b
Returns
Element

◆ moveFormatTagOutsideATag()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::moveFormatTagOutsideATag ( Element $node)

When an A tag is encountered, if there are format tags inside, move them outside Also merge a single sibling A tag that is mergable The link href and text must match for this normalization to take effect.

Parameters
Element$node
Returns
Node|null

◆ normalize()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::normalize ( Node $node)
Parameters
Element | DocumentFragment$node

◆ normalizeNode()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::normalizeNode ( Node $node)

Wikitext normalizations implemented right now:

  1. Tag minimization (I/B tags) in normalizeSiblingPair
  2. Strip empty headings and style tags
  3. Force SOL transparent links to serialize before/after heading
  4. Trailing spaces are migrated out of links
  5. Space is added before escapable prefixes in table cells
  6. Strip
    from headings
  7. Strip bidi chars around categories
  8. When an A tag is encountered, if there are format tags inside, move them outside

The return value from this function should respect the following contract:

  • if input node is unmodified, return it.
  • if input node is modified, return the new node that it transforms into. If you return a node other than this, normalizations may not apply cleanly and may be skipped.
Parameters
Node$node
Returns
Node|null the normalized node

◆ stripBidiCharsAroundCategories()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::stripBidiCharsAroundCategories ( Node $node)

◆ swap()

Wikimedia\Parsoid\Html2Wt\DOMNormalizer::swap ( Element $a,
Element $b )

b is a's sole non-deleted child.

Switch them around.

Parameters
Element$a
Element$b
Returns
Element

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