Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter Class Reference

DOM pass that walks the DOM tree, detects specific wikitext patterns, and emits them as linter events. More...

+ Inheritance diagram for Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter:
+ Collaboration diagram for Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter:

Public Member Functions

 run (Env $env, Node $root, array $options=[], bool $atTopLevel=false)
 This is only invoked on the top-level document
Parameters
Env$env
Element | DocumentFragment$rootThe root of the tree to process
array$options
bool$atTopLevelIs this processor invoked on the top level page? If false, this is being invoked in a sub-pipeline (ex: extensions)
.
 

Static Public Member Functions

static findEnclosingTemplateName (Env $env, ?stdClass $tplInfo)
 Given a tplInfo object, determine whether we are:
 
static findLintDSR (?array $tplLintInfo, ?stdClass $tplInfo, ?DomSourceRange $nodeDSR, ?callable $updateNodeDSR=null)
 Compute the DSR information for the lint object.
 

Detailed Description

DOM pass that walks the DOM tree, detects specific wikitext patterns, and emits them as linter events.

Member Function Documentation

◆ findEnclosingTemplateName()

static Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter::findEnclosingTemplateName ( Env $env,
?stdClass $tplInfo )
static

Given a tplInfo object, determine whether we are:

  • Not processing template content (could be extension or top level page)
  • Processing encapsulated content that is produced by a single template. If so, return the name of that template.
  • Processing encapsulated content that comes from multiple templates. If so, return a flag indicating this.

FIXME: We might potentially be computing this information redundantly for every lint we find within this template's content. It could probably be cached in tplInfo after it is computed once.

◆ findLintDSR()

static Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter::findLintDSR ( ?array $tplLintInfo,
?stdClass $tplInfo,
?DomSourceRange $nodeDSR,
?callable $updateNodeDSR = null )
static

Compute the DSR information for the lint object.

  • In the common case, this is simply the DSR value of the node that generated the lint. But, occasionally, for some lints, we might have to post-process the node's DSR.
  • If the lint is found in template content, then the DSR spans the transclusion markup in the toplevel page source.

◆ run()

Wikimedia\Parsoid\Wt2Html\DOM\Processors\Linter::run ( Env $env,
Node $root,
array $options = [],
bool $atTopLevel = false )

This is only invoked on the top-level document

Parameters
Env$env
Element | DocumentFragment$rootThe root of the tree to process
array$options
bool$atTopLevelIs this processor invoked on the top level page? If false, this is being invoked in a sub-pipeline (ex: extensions)
.

Implements Wikimedia\Parsoid\Wt2Html\Wt2HtmlDOMProcessor.


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