MediaWiki 1.43.1
Preprocessor.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Parser;
25
27
31abstract class Preprocessor {
33 public const DOM_FOR_INCLUSION = 1;
37 public const DOM_UNCACHED = 4;
38
40 public $parser;
41
43 protected $wanCache;
44
47
49 protected $rules = [
50 '{' => [
51 'end' => '}',
52 'names' => [
53 2 => 'template',
54 3 => 'tplarg',
55 ],
56 'min' => 2,
57 'max' => 3,
58 ],
59 '[' => [
60 'end' => ']',
61 'names' => [ 2 => null ],
62 'min' => 2,
63 'max' => 2,
64 ],
65 '-{' => [
66 'end' => '}-',
67 'names' => [ 2 => null ],
68 'min' => 2,
69 'max' => 2,
70 ],
71 ];
72
79 public function __construct(
82 array $options = []
83 ) {
84 $this->parser = $parser;
85 $this->wanCache = $wanCache ?: WANObjectCache::newEmpty();
86 $this->disableLangConversion = !empty( $options['disableLangConversion'] );
87 }
88
99 public function resetParser( ?Parser $parser ) {
100 // @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty For internal use only
101 $this->parser = $parser;
102 }
103
109 abstract public function newFrame();
110
119 abstract public function newCustomFrame( $args );
120
128 abstract public function newPartNodeArray( $values );
129
149 abstract public function preprocessToObj( $text, $flags = 0 );
150}
151
153class_alias( Preprocessor::class, 'Preprocessor' );
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:143
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.