I wrote:
...the StripState class looks remarkably closed. All the members are protected (not public), and I didn't see any accessor functions to change the values of strip markers.
I worked around this by defining a subclass of StripState, MyStripState, that can change those protected members:
class MyStripState extends StripState { function __construct($parentStripState) { // Copy the parent into me. // This will break if StripState gets new public/protected members. parent::__construct($parentStripState->prefix); $this->data = $parentStripState->data; $this->regex = $parentStripState->regex; $this->tempType = $parentStripState->tempType; $this->tempMergePrefix = $parentStripState->tempMergePrefix; } function modifyTheStuffINeed() { $this->data = whatever...; } }
Then I substitute my extended StripState class for the real one:
$wgHooks['InternalParseBeforeLinks'][] = 'MyParserFunction::render'; class MyParserFunction { static function render(&$parser, &$text, &$stripState) { $ss = new MyStripState ($stripState); $ssw-> modifyTheStuffINeed(); $stripState = $ss; return true; } }|
and it works. Hopefully not too much of a hack.
DanB