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) 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 model](http://nvie.com/git-model) (knowing that there are [alternative
workflows](http://scottchacon.com/2011/08/31/github-flow.html)). 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 Contributors
------------ ------------

View File

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

View File

@ -155,8 +155,8 @@ class Extension {
self::$targetTitleText = self::$targetTitle->getText(); self::$targetTitleText = self::$targetTitle->getText();
$quotedTitle = preg_quote( self::$targetTitleText, '/' ); $quotedTitle = preg_quote( self::$targetTitleText, '/' );
self::ltDebugLog('TargetTitle='. self::$targetTitleText,"private"); self::ltDebugLog( 'TargetTitle='. self::$targetTitleText, 'private' );
self::ltDebugLog('TargetTitleQuoted='. $quotedTitle,"private"); self::ltDebugLog( 'TargetTitleQuoted='. $quotedTitle, 'private' );
// Depending on the global configuration setting $wgCapitalLinks, // Depending on the global configuration setting $wgCapitalLinks,
// the title has to be searched for either in a strictly case-sensitive // the title has to be searched for either in a strictly case-sensitive
@ -247,6 +247,27 @@ class Extension {
return true; 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. // 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 ) {
@ -443,7 +464,9 @@ private static function BuildDelimiters() {
if ( $wgLinkTitlesSkipTemplates ) if ( $wgLinkTitlesSkipTemplates )
{ {
$templatesDelimiter = '{{[^}]+}}|'; // Use recursive regex to balance curly braces;
// see http://www.regular-expressions.info/recurse.html
$templatesDelimiter = '{{(?>[^{}]|(?R))*}}|';
} else { } else {
// Match template names (ignoring any piped [[]] links in them) // Match template names (ignoring any piped [[]] links in them)
// along with the trailing pipe and parameter name or closing // along with the trailing pipe and parameter name or closing
@ -478,6 +501,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';
@ -485,8 +509,7 @@ private static function BuildDelimiters() {
/// Local Debugging output function which can send output to console as well /// Local Debugging output function which can send output to console as well
public static function ltDebugLog($text) { public static function ltDebugLog($text) {
if (self::$ltConsoleOutputDebug) if ( self::$ltConsoleOutputDebug ) {
{
print $text . "\n"; print $text . "\n";
} }
wfDebugLog( 'LinkTitles', $text , 'private' ); wfDebugLog( 'LinkTitles', $text , 'private' );
@ -494,8 +517,7 @@ private static function BuildDelimiters() {
/// Local Logging output function which can send output to console as well /// Local Logging output function which can send output to console as well
public static function ltLog($text) { public static function ltLog($text) {
if (self::$ltConsoleOutput) if (self::$ltConsoleOutput) {
{
print $text . "\n"; print $text . "\n";
} }
wfDebugLog( 'LinkTitles', $text , 'private' ); wfDebugLog( 'LinkTitles', $text , 'private' );