Jackmcbarn has uploaded a new change for review. https://gerrit.wikimedia.org/r/181046
Change subject: Allow running code during unstrip ...................................................................... Allow running code during unstrip When adding strip markers, allow closures to be passed in place of text. The closure is then called during unstrip. Also, add a hook that runs after unstripGeneral. Change-Id: If83b0623671fd67e5ccc9deaaaab456a6679af8f --- M docs/hooks.txt M includes/parser/Parser.php M includes/parser/StripState.php 3 files changed, 13 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/46/181046/1 diff --git a/docs/hooks.txt b/docs/hooks.txt index f83a6c3..a3d490d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2019,6 +2019,10 @@ $parser: Parser object being used $text: text that will be returned +'ParserAfterUnstrip': Called after the first unstripGeneral() in Parser::internalParseHalfParsed() +$parser: Parser object being used +$text: text that will be returned + 'ParserBeforeInternalParse': Called at the beginning of Parser::internalParse(). $parser: Parser object $text: text to parse diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ecb14ed..528e5eb 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1293,6 +1293,10 @@ $text = $this->mStripState->unstripGeneral( $text ); + if ( $isMain ) { + Hooks::run( 'ParserAfterUnstrip', array( &$this, &$text ) ); + } + # Clean up special characters, only run once, next-to-last before doBlockLevels $fixtags = array( # french spaces, last one Guillemet-left diff --git a/includes/parser/StripState.php b/includes/parser/StripState.php index 5d1743e..8596268 100644 --- a/includes/parser/StripState.php +++ b/includes/parser/StripState.php @@ -146,7 +146,11 @@ } $this->circularRefGuard[$marker] = true; $this->recursionLevel++; - $ret = $this->unstripType( $this->tempType, $this->data[$this->tempType][$marker] ); + $value = $this->data[$this->tempType][$marker]; + if ( $value instanceof Closure ) { + $value = $value(); + } + $ret = $this->unstripType( $this->tempType, $value ); $this->recursionLevel--; unset( $this->circularRefGuard[$marker] ); return $ret; -- To view, visit https://gerrit.wikimedia.org/r/181046 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If83b0623671fd67e5ccc9deaaaab456a6679af8f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jackmcbarn <jackmcb...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits