MediaWiki master
MediaWiki\Parser\Preprocessor_Hash Class Reference

Differences from DOM schema: More...

Inherits MediaWiki\Parser\Preprocessor.

Collaboration diagram for MediaWiki\Parser\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.
 
- Public Member Functions inherited from MediaWiki\Parser\Preprocessor
 resetParser (?Parser $parser)
 Allows resetting the internal Parser reference after Preprocessor is cloned.
 

Protected Attributes

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

Additional Inherited Members

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

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 47 of file Preprocessor_Hash.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Parser\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 MediaWiki\Parser\Preprocessor.

Definition at line 61 of file Preprocessor_Hash.php.

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

Member Function Documentation

◆ newCustomFrame()

MediaWiki\Parser\Preprocessor_Hash::newCustomFrame ( $args)
Parameters
array$args
Returns
PPCustomFrame_Hash

Reimplemented from MediaWiki\Parser\Preprocessor.

Definition at line 82 of file Preprocessor_Hash.php.

◆ newFrame()

MediaWiki\Parser\Preprocessor_Hash::newFrame ( )
Returns
PPFrame_Hash

Reimplemented from MediaWiki\Parser\Preprocessor.

Definition at line 74 of file Preprocessor_Hash.php.

◆ newPartNodeArray()

MediaWiki\Parser\Preprocessor_Hash::newPartNodeArray ( $values)
Parameters
array$values
Returns
PPNode_Hash_Array

Reimplemented from MediaWiki\Parser\Preprocessor.

Definition at line 90 of file Preprocessor_Hash.php.

◆ preprocessToObj()

MediaWiki\Parser\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 MediaWiki\Parser\Preprocessor.

Definition at line 113 of file Preprocessor_Hash.php.

References MediaWiki\Parser\Preprocessor_Hash\CACHE_VERSION, and MediaWiki\Parser\Preprocessor\DOM_LANG_CONVERSION_DISABLED.

Member Data Documentation

◆ $cacheThreshold

int false MediaWiki\Parser\Preprocessor_Hash::$cacheThreshold
protected

Min wikitext size for which to cache DOM tree.

Definition at line 52 of file Preprocessor_Hash.php.

◆ CACHE_VERSION

const MediaWiki\Parser\Preprocessor_Hash::CACHE_VERSION = 4
protected

Cache format version.

Definition at line 49 of file Preprocessor_Hash.php.

Referenced by MediaWiki\Parser\Preprocessor_Hash\preprocessToObj().


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