mirror of
				https://github.com/diocloid/LinkTitles.git
				synced 2025-10-22 05:42:32 +02:00 
			
		
		
		
	Add support for <noautolinks> tag.
- New: Mark sections that are not to be automatically linked with the new `<noautolinks>..</noautolinks>` tag. Addresses #29.
This commit is contained in:
		@@ -56,6 +56,9 @@
 | 
			
		||||
                ],
 | 
			
		||||
                "GetDoubleUnderscoreIDs": [
 | 
			
		||||
                        "LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
 | 
			
		||||
                ],
 | 
			
		||||
                "ParserFirstCallInit": [
 | 
			
		||||
                        "LinkTitles\\Extension::onParserFirstCallInit"
 | 
			
		||||
                ]
 | 
			
		||||
        },
 | 
			
		||||
        "callback": "LinkTitles\\Extension::setup",
 | 
			
		||||
 
 | 
			
		||||
@@ -247,6 +247,17 @@ class Extension {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static function onParserFirstCallInit( \Parser $parser ) {
 | 
			
		||||
		$parser->setHook( 'noautolinks', 'LinkTitles\Extension::removeExtraTags' );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	///	Removes the extra tag that this extension provides (<noautolinks>)
 | 
			
		||||
	///	by simply returning the text between the tags (if any).
 | 
			
		||||
	///	See https://www.mediawiki.org/wiki/Manual:Tag_extensions#Example
 | 
			
		||||
	public static function removeExtraTags( $input, array $args, \Parser $parser, \PPFrame $frame ) {
 | 
			
		||||
		return htmlspecialchars( $input );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Fetches the page titles from the database.
 | 
			
		||||
	// @param $currentNamespace String holding the namespace of the page currently being processed.
 | 
			
		||||
	private static function fetchPageTitles( $currentNamespace ) {
 | 
			
		||||
@@ -478,6 +489,7 @@ private static function BuildDelimiters() {
 | 
			
		||||
			'<span.+?>|<\/span>|' .                     // attributes of span elements
 | 
			
		||||
			'<file>[^<]*<\/file>|' .                    // stuff inside file elements
 | 
			
		||||
			'style=".+?"|class=".+?"|' .                // styles and classes (e.g. of wikitables)
 | 
			
		||||
			'<noautolinks>.*?<\/noautolinks>|' .        // custom tag 'noautolinks'
 | 
			
		||||
			'\[' . $urlPattern . '\s.+?\]|'. $urlPattern .  '(?=\s|$)|' . // urls
 | 
			
		||||
			'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' .        // email addresses
 | 
			
		||||
			')/ismS';
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user