diff --git a/NEWS b/NEWS
index 07892fa..0c1d448 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,19 @@
+Version 7.1.0 (2017-08-24)
+------------------------------------------------------------------------
+
+- New: Mark sections that are not to be automatically linked with the new `..` tag.
+- New: Mark sections that are to be automatically linked with the new `..` 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)
------------------------------------------------------------------------
- Fix: __NOAUTOLINKS__ was not respected during rendering.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.8 (2017-02-16)
@@ -13,7 +23,7 @@ Version 4.0.8 (2017-02-16)
- Fix: The special page and the maintenance script did not work in MW 1.28.
- Fix: The special page did not work.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.7 (2017-01-02)
@@ -21,7 +31,7 @@ Version 4.0.7 (2017-01-02)
- Improvement: Increase performance of special page and maintenance script.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.6 (2016-12-28)
@@ -30,7 +40,7 @@ Version 4.0.6 (2016-12-28)
- Fix: Bug fixes.
- Fix: Custom namespace weights were not respected.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.5 (2016-12-14)
@@ -40,7 +50,7 @@ Version 4.0.5 (2016-12-14)
- Fix: Remove leftover error log call.
- Improvement: Refactored maintenance script, improving user interaction.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.4 (2016-11-30)
@@ -48,7 +58,7 @@ Version 4.0.4 (2016-11-30)
- Fix: Do not link titles twice if $wgLinkTitlesFirstOnly and $wgLinkTitlesSmartMode are both true.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.3 (2016-11-22)
@@ -56,7 +66,7 @@ Version 4.0.3 (2016-11-22)
- Fix: __NOAUTOLINKS__ magic word would not be respected when saving an edited page.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.2 (2016-11-09)
@@ -65,7 +75,7 @@ Version 4.0.2 (2016-11-09)
- FIX: Removed a fatal bug in the LinkTitles_Maintenance script.
- FIX: Repaired severely broken namespaces support.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.1 (2016-11-08)
@@ -73,7 +83,7 @@ Version 4.0.1 (2016-11-08)
- FIX: Prevent syntax error when accessing special page.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.0 (2016-11-05)
@@ -85,7 +95,7 @@ Version 4.0.0 (2016-11-05)
- NEW: Support namespaces.
- NEW: Use the new extension format introduced by MediaWiki 1.25; the extension will no longer run with older MediaWiki versions.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 3.1.0. (2015-02-05)
@@ -93,7 +103,7 @@ Version 3.1.0. (2015-02-05)
- IMPROVEMENT: Do not link inside ... tags.
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
diff --git a/README.md b/README.md
index 3dcafe3..dc88414 100644
--- a/README.md
+++ b/README.md
@@ -17,11 +17,14 @@ This extension is [semantically versioned](http://semver.org).
Contributing
------------
-If you wish to contribute, please issue pull requests against the `develop`
-branch, as I follow Vincent Driessen's advice on [A successful Git branching
-model](http://nvie.com/git-model) (knowing that there are [alternative
+If you wish to contribute, please issue pull requests against the `develop`
+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
------------
diff --git a/extension.json b/extension.json
index e732b07..fe3ee4a 100644
--- a/extension.json
+++ b/extension.json
@@ -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",
diff --git a/gh-pages b/gh-pages
index 2dec0ce..076be77 160000
--- a/gh-pages
+++ b/gh-pages
@@ -1 +1 @@
-Subproject commit 2dec0ce8a6864c2c1169710fe206175c4c58b940
+Subproject commit 076be774a2dcf5d625adf292c7fd97bddc4bfddd
diff --git a/includes/LinkTitles_Extension.php b/includes/LinkTitles_Extension.php
index 5fffa3e..31e4c72 100644
--- a/includes/LinkTitles_Extension.php
+++ b/includes/LinkTitles_Extension.php
@@ -45,8 +45,8 @@ class Extension {
/// A Title object for the target page currently being examined.
private static $targetTitle;
- // The TitleValue object of the target page
- private static $targetTitleValue;
+ // The TitleValue object of the target page
+ private static $targetTitleValue;
/// The content object for the currently processed target page.
/// This variable is necessary to be able to prevent loading the target
@@ -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 ()
+ /// 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 ()
+ /// 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,28 +501,27 @@ private static function BuildDelimiters() {
'|<\/span>|' . // attributes of span elements
'[^<]*<\/file>|' . // stuff inside file elements
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
+ '.*?<\/noautolinks>|' . // custom tag 'noautolinks'
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
')/ismS';
+ }
+
+ /// Local Debugging output function which can send output to console as well
+ public static function ltDebugLog($text) {
+ if ( self::$ltConsoleOutputDebug ) {
+ print $text . "\n";
}
+ wfDebugLog( 'LinkTitles', $text , 'private' );
+ }
- /// Local Debugging output function which can send output to console as well
- public static function ltDebugLog($text) {
- if (self::$ltConsoleOutputDebug)
- {
- print $text . "\n";
- }
- wfDebugLog('LinkTitles', $text , 'private');
- }
-
- /// Local Logging output function which can send output to console as well
- public static function ltLog($text) {
- if (self::$ltConsoleOutput)
- {
- print $text . "\n";
- }
- wfDebugLog('LinkTitles', $text , 'private');
- }
+ /// Local Logging output function which can send output to console as well
+ public static function ltLog($text) {
+ if (self::$ltConsoleOutput) {
+ print $text . "\n";
+ }
+ wfDebugLog( 'LinkTitles', $text , 'private' );
+ }
}
// vim: ts=2:sw=2:noet:comments^=\:///