mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 01:39:30 +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": [
|
"GetDoubleUnderscoreIDs": [
|
||||||
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
|
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
|
||||||
|
],
|
||||||
|
"ParserFirstCallInit": [
|
||||||
|
"LinkTitles\\Extension::onParserFirstCallInit"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"callback": "LinkTitles\\Extension::setup",
|
"callback": "LinkTitles\\Extension::setup",
|
||||||
|
@ -247,6 +247,17 @@ class Extension {
|
|||||||
return true;
|
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.
|
// Fetches the page titles from the database.
|
||||||
// @param $currentNamespace String holding the namespace of the page currently being processed.
|
// @param $currentNamespace String holding the namespace of the page currently being processed.
|
||||||
private static function fetchPageTitles( $currentNamespace ) {
|
private static function fetchPageTitles( $currentNamespace ) {
|
||||||
@ -478,6 +489,7 @@ private static function BuildDelimiters() {
|
|||||||
'<span.+?>|<\/span>|' . // attributes of span elements
|
'<span.+?>|<\/span>|' . // attributes of span elements
|
||||||
'<file>[^<]*<\/file>|' . // stuff inside file elements
|
'<file>[^<]*<\/file>|' . // stuff inside file elements
|
||||||
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
|
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
|
||||||
|
'<noautolinks>.*?<\/noautolinks>|' . // custom tag 'noautolinks'
|
||||||
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
|
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
|
||||||
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
|
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
|
||||||
')/ismS';
|
')/ismS';
|
||||||
|
Reference in New Issue
Block a user