mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +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:
@ -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