mirror of
				https://github.com/diocloid/LinkTitles.git
				synced 2025-10-22 05:42:32 +02:00 
			
		
		
		
	Implement <autolinks> tag.
- New: Mark sections that are to be automatically linked with the new `<autolinks>..</autolinks>` tag. This tag only makes sense on pages with the `__NOAUTOLINKS__` magic word, or if both `$wgLinkTitlesParseOnEdit` and `$wgLinkTitlesParseOnRender` are set to false. Note that this tag is parsed when a page is rendered, not when it is saved. Therefore, the links will not appear in the page source. Addresses #29.
This commit is contained in:
		@@ -248,16 +248,26 @@ class Extension {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static function onParserFirstCallInit( \Parser $parser ) {
 | 
			
		||||
		$parser->setHook( 'noautolinks', 'LinkTitles\Extension::removeExtraTags' );
 | 
			
		||||
		$parser->setHook( 'noautolinks', 'LinkTitles\Extension::doNoautolinksTag' );
 | 
			
		||||
		$parser->setHook( 'autolinks', 'LinkTitles\Extension::doAutolinksTag' );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	///	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 ) {
 | 
			
		||||
	public static function doNoautolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
 | 
			
		||||
		return htmlspecialchars( $input );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	///	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#How_do_I_render_wikitext_in_my_extension.3F
 | 
			
		||||
	public static function doAutolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
 | 
			
		||||
		$withLinks = self::parseContent( $parser->getTitle(), $input );
 | 
			
		||||
		$output = $parser->recursiveTagParse( $withLinks, $frame );
 | 
			
		||||
		return $output;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Fetches the page titles from the database.
 | 
			
		||||
	// @param $currentNamespace String holding the namespace of the page currently being processed.
 | 
			
		||||
	private static function fetchPageTitles( $currentNamespace ) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user