Merge branch 'release-4.1.0'

This commit is contained in:
Daniel Kraus
2017-08-25 19:31:40 +02:00
5 changed files with 81 additions and 43 deletions

10
NEWS
View File

@ -1,3 +1,13 @@
Version 7.1.0 (2017-08-24)
------------------------------------------------------------------------
- New: Mark sections that are not to be automatically linked with the new `<noautolinks>..</noautolinks>` 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.
- Fix: Properly handle templates that include other templates.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.9 (2017-03-21)
------------------------------------------------------------------------

View File

@ -22,6 +22,9 @@ branch, as I follow Vincent Driessen's advice on [A successful Git branching
model](http://nvie.com/git-model) (knowing that there are [alternative
workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
The `master` branch contains stable releases only, so it is safe to pull the
master branch if you want to install the extension for your own wiki.
Contributors
------------

View File

@ -7,7 +7,7 @@
],
"type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
"version": "4.0.9",
"version": "4.1.0",
"license-name": "GPL-2.0+",
"descriptionmsg": "linktitles-desc",
"requires": {
@ -56,6 +56,9 @@
],
"GetDoubleUnderscoreIDs": [
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
],
"ParserFirstCallInit": [
"LinkTitles\\Extension::onParserFirstCallInit"
]
},
"callback": "LinkTitles\\Extension::setup",

View File

@ -153,10 +153,10 @@ class Extension {
// Escape certain special characters in the page title to prevent
// regexp compilation errors
self::$targetTitleText = self::$targetTitle->getText();
$quotedTitle = preg_quote(self::$targetTitleText, '/');
$quotedTitle = preg_quote( self::$targetTitleText, '/' );
self::ltDebugLog('TargetTitle='. self::$targetTitleText,"private");
self::ltDebugLog('TargetTitleQuoted='. $quotedTitle,"private");
self::ltDebugLog( 'TargetTitle='. self::$targetTitleText, 'private' );
self::ltDebugLog( 'TargetTitleQuoted='. $quotedTitle, 'private' );
// Depending on the global configuration setting $wgCapitalLinks,
// the title has to be searched for either in a strictly case-sensitive
@ -247,6 +247,27 @@ class Extension {
return true;
}
public static function onParserFirstCallInit( \Parser $parser ) {
$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 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 ) {
@ -424,10 +445,10 @@ class Extension {
return true;
}
/// Builds the delimiter that is used in a regexp to separate
/// text that should be parsed from text that should not be
/// parsed (e.g. inside existing links etc.)
private static function BuildDelimiters() {
/// Builds the delimiter that is used in a regexp to separate
/// text that should be parsed from text that should not be
/// parsed (e.g. inside existing links etc.)
private static function BuildDelimiters() {
// Configuration variables need to be defined here as globals.
global $wgLinkTitlesParseHeadings;
global $wgLinkTitlesSkipTemplates;
@ -443,7 +464,9 @@ private static function BuildDelimiters() {
if ( $wgLinkTitlesSkipTemplates )
{
$templatesDelimiter = '{{[^}]+}}|';
// Use recursive regex to balance curly braces;
// see http://www.regular-expressions.info/recurse.html
$templatesDelimiter = '{{(?>[^{}]|(?R))*}}|';
} else {
// Match template names (ignoring any piped [[]] links in them)
// along with the trailing pipe and parameter name or closing
@ -478,6 +501,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';
@ -485,20 +509,18 @@ private static function BuildDelimiters() {
/// Local Debugging output function which can send output to console as well
public static function ltDebugLog($text) {
if (self::$ltConsoleOutputDebug)
{
if ( self::$ltConsoleOutputDebug ) {
print $text . "\n";
}
wfDebugLog('LinkTitles', $text , 'private');
wfDebugLog( 'LinkTitles', $text , 'private' );
}
/// Local Logging output function which can send output to console as well
public static function ltLog($text) {
if (self::$ltConsoleOutput)
{
if (self::$ltConsoleOutput) {
print $text . "\n";
}
wfDebugLog('LinkTitles', $text , 'private');
wfDebugLog( 'LinkTitles', $text , 'private' );
}
}