Fix <noautolinks> tag in parse-on-render mode.

- Fix: <noautolinks> tag did not work in parse-on-render mode.
This commit is contained in:
Daniel Kraus
2017-09-06 22:31:59 +02:00
parent c99ec87b87
commit 04c1be307b
4 changed files with 69 additions and 10 deletions

View File

@ -46,6 +46,8 @@ class Linker {
*/
private $linkValue;
private static $locked = 0;
/**
* Constructs a new instance of the Linker class.
*
@ -68,7 +70,7 @@ class Linker {
* @return String|null Source page text with links to target pages, or null if no links were added
*/
public function linkContent( Source $source ) {
if ( !$source->canBeLinked() ) {
if ( self::$locked > 0 || !$source->canBeLinked() ) {
return;
}
@ -197,6 +199,28 @@ class Linker {
return '[[' . $matches[ 0 ] . ']]';
}
}
/**
* Increases an internal static lock counter by 1.
*
* If the Linker class is locked (counter > 0), linkContent() will be a no-op.
* Locking is necessary to enable nested <noautolinks> and <autolinks> tags in
* parseOnRender mode.
*/
public static function lock() {
self::$locked += 1;
}
/**
* Decreases an internal static lock counter by 1.
*
* If the Linker class is locked (counter > 0), linkContent() will be a no-op.
* Locking is necessary to enable nested <noautolinks> and <autolinks> tags in
* parseOnRender mode.
*/
public static function unlock() {
self::$locked -= 1;
}
}
// vim: ts=2:sw=2:noet:comments^=\:///