MediaWiki master
Preprocessor.php
Go to the documentation of this file.
1<?php
10namespace MediaWiki\Parser;
11
13
17abstract class Preprocessor {
19 public const DOM_FOR_INCLUSION = 1;
23 public const DOM_UNCACHED = 4;
24 // Does preprocessing start in Start-Of-Line(SOL) state? Only relevant for Parsoid
25 // content, since Parsoid models templates as independent documents in SOL start.
26 // This flag is never set by the legacy parser (but see T2529 which has a similar
27 // effect).
28 public const START_IN_SOL_STATE = 8;
29
31 public $parser;
32
34 protected $wanCache;
35
38
40 protected $rules = [
41 '{' => [
42 'end' => '}',
43 'names' => [
44 2 => 'template',
45 3 => 'tplarg',
46 ],
47 'min' => 2,
48 'max' => 3,
49 ],
50 '[' => [
51 'end' => ']',
52 'names' => [ 2 => null ],
53 'min' => 2,
54 'max' => 2,
55 ],
56 '-{' => [
57 'end' => '}-',
58 'names' => [ 2 => null ],
59 'min' => 2,
60 'max' => 2,
61 ],
62 ];
63
70 public function __construct(
73 array $options = []
74 ) {
75 $this->parser = $parser;
76 $this->wanCache = $wanCache ?: WANObjectCache::newEmpty();
77 $this->disableLangConversion = !empty( $options['disableLangConversion'] );
78 }
79
90 public function resetParser( ?Parser $parser ) {
91 // @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty For internal use only
92 $this->parser = $parser;
93 }
94
100 abstract public function newFrame();
101
110 abstract public function newCustomFrame( $args );
111
119 abstract public function newPartNodeArray( $values );
120
140 abstract public function preprocessToObj( $text, $flags = 0 );
141}
142
144class_alias( Preprocessor::class, 'Preprocessor' );
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:135
resetParser(?Parser $parser)
Allows resetting the internal Parser reference after Preprocessor is cloned.
__construct(Parser $parser, ?WANObjectCache $wanCache=null, array $options=[])
newPartNodeArray( $values)
Create a new custom node for programmatic use of parameter replacement.
newFrame()
Create a new top-level frame for expansion of a page.
const DOM_UNCACHED
Preprocessor cache bypass flag for Preprocessor::preprocessToObj.
const DOM_LANG_CONVERSION_DISABLED
Language conversion construct omission flag for Preprocessor::preprocessToObj()
preprocessToObj( $text, $flags=0)
Get the document object model for the given wikitext.
const DOM_FOR_INCLUSION
Transclusion mode flag for Preprocessor::preprocessToObj()
newCustomFrame( $args)
Create a new custom frame for programmatic use of parameter replacement.
array $rules
Brace matching rules.
bool $disableLangConversion
Whether language variant conversion is disabled.
Multi-datacenter aware caching interface.