MediaWiki  master
Preprocessor_Hash Class Reference

Differences from DOM schema: More...

Inheritance diagram for Preprocessor_Hash:
Collaboration diagram for Preprocessor_Hash:

Public Member Functions

 __construct (Parser $parser, WANObjectCache $wanCache=null, array $options=[])
 
 newCustomFrame ( $args)
 
 newFrame ()
 
 newPartNodeArray ( $values)
 
 preprocessToObj ( $text, $flags=0)
 Get the document object model for the given wikitext. More...
 

Protected Attributes

int bool $cacheThreshold
 Min wikitext size for which to cache DOM tree. More...
 
const CACHE_VERSION = 3
 Cache format version. More...
 
- Protected Attributes inherited from Preprocessor
bool $disableLangConversion
 Whether language variant conversion is disabled. More...
 
array $rules
 Brace matching rules. More...
 
WANObjectCache $wanCache
 

Private Member Functions

 buildDomTreeArrayFromText ( $text, $flags)
 

Static Private Member Functions

static addLiteral (array &$accum, $text)
 

Additional Inherited Members

- Public Attributes inherited from Preprocessor
Parser $parser
 
const DOM_FOR_INCLUSION = 1
 Transclusion mode flag for Preprocessor::preprocessToObj() More...
 
const DOM_LANG_CONVERSION_DISABLED = 2
 Language conversion construct omission flag for Preprocessor::preprocessToObj() More...
 
const DOM_UNCACHED = 4
 Preprocessor cache bypass flag for Preprocessor::preprocessToObj. More...
 

Detailed Description

Differences from DOM schema:

  • attribute nodes are children
  • "<h>" nodes that aren't at the top are replaced with <possible-h>

Nodes are stored in a recursive array data structure. A node store is an array where each element may be either a scalar (representing a text node) or a "descriptor", which is a two-element array where the first element is the node name and the second element is the node store for the children.

Attributes are represented as children that have a node name starting with "@", and a single text node child.

Todo:
: Consider replacing descriptor arrays with objects of a new class. Benchmark and measure resulting memory impact.

Definition at line 43 of file Preprocessor_Hash.php.

Constructor & Destructor Documentation

◆ __construct()

Preprocessor_Hash::__construct ( Parser  $parser,
WANObjectCache  $wanCache = null,
array  $options = [] 
)
See also
Preprocessor::__construct()
Parameters
Parser$parser
WANObjectCache | null$wanCache
array$optionsAdditional options include:
  • cacheThreshold: min text size for which to cache DOMs. [Default: false]

Reimplemented from Preprocessor.

Definition at line 57 of file Preprocessor_Hash.php.

References Preprocessor\$parser, and Preprocessor\$wanCache.

Member Function Documentation

◆ addLiteral()

static Preprocessor_Hash::addLiteral ( array &  $accum,
  $text 
)
staticprivate

Definition at line 794 of file Preprocessor_Hash.php.

Referenced by buildDomTreeArrayFromText().

◆ buildDomTreeArrayFromText()

Preprocessor_Hash::buildDomTreeArrayFromText (   $text,
  $flags 
)
private
Parameters
string$textWikitext
int$flagsBit field of Preprocessor::DOM_* flags
Returns
array JSON-serializable document object model array

Definition at line 140 of file Preprocessor_Hash.php.

References $matches, addLiteral(), Preprocessor\DOM_FOR_INCLUSION, and Preprocessor\DOM_LANG_CONVERSION_DISABLED.

Referenced by preprocessToObj().

◆ newCustomFrame()

Preprocessor_Hash::newCustomFrame (   $args)
Parameters
array$args
Returns
PPCustomFrame_Hash

Reimplemented from Preprocessor.

Definition at line 78 of file Preprocessor_Hash.php.

References $args.

◆ newFrame()

Preprocessor_Hash::newFrame ( )
Returns
PPFrame_Hash

Reimplemented from Preprocessor.

Definition at line 70 of file Preprocessor_Hash.php.

◆ newPartNodeArray()

Preprocessor_Hash::newPartNodeArray (   $values)
Parameters
array$values
Returns
PPNode_Hash_Array

Reimplemented from Preprocessor.

Definition at line 86 of file Preprocessor_Hash.php.

◆ preprocessToObj()

Preprocessor_Hash::preprocessToObj (   $text,
  $flags = 0 
)

Get the document object model for the given wikitext.

Any flag added to the $flags parameter here, or any other parameter liable to cause a change in the DOM tree for the given wikitext, must be passed through the section identifier in the section edit link and thus back to extractSections().

Parameters
string$textWikitext
int$flagsBit field of Preprocessor::DOM_* flags:
  • Preprocessor::DOM_FOR_INCLUSION: treat the wikitext as transcluded content from a page rather than direct content of a page or message. By default, the text is assumed to be undergoing processing for use by direct page views. The use of this flag causes text within <noinclude> tags to be ignored, text within <includeonly> to be included, and text outside of <onlyinclude> to be ignored.
  • Preprocessor::DOM_NO_LANG_CONV: do not parse "-{ ... }-" constructs, which are involved in language variant conversion. (deprecated since 1.36)
  • Preprocessor::DOM_UNCACHED: disable use of the preprocessor cache.
Returns
PPNode

Reimplemented from Preprocessor.

Definition at line 109 of file Preprocessor_Hash.php.

References buildDomTreeArrayFromText(), CACHE_VERSION, and Preprocessor\DOM_LANG_CONVERSION_DISABLED.

Member Data Documentation

◆ $cacheThreshold

int bool Preprocessor_Hash::$cacheThreshold
protected

Min wikitext size for which to cache DOM tree.

Definition at line 48 of file Preprocessor_Hash.php.

◆ CACHE_VERSION

const Preprocessor_Hash::CACHE_VERSION = 3
protected

Cache format version.

Definition at line 45 of file Preprocessor_Hash.php.

Referenced by preprocessToObj().


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