mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 01:39:30 +02:00
Fix <noautolinks> tag in parse-on-render mode.
- Fix: <noautolinks> tag did not work in parse-on-render mode.
This commit is contained in:
@ -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^=\:///
|
||||
|
Reference in New Issue
Block a user