Skip to content

Commit

Permalink
Merge branch 'release-5.0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
bovender committed Jun 27, 2018
2 parents 9e6b6a4 + bd7b6b1 commit ce50459
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 5.0.7 (2018-06-27)
------------------------------------------------------------------------

- Fix: Improve handling of page titles that start or end with numbers.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Version 5.0.6 (2018-06-20)
------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
"version": "5.0.6",
"version": "5.0.7",
"license-name": "GPL-2.0+",
"descriptionmsg": "linktitles-desc",
"requires": {
Expand Down
2 changes: 1 addition & 1 deletion gh-pages
Submodule gh-pages updated 151 files
4 changes: 2 additions & 2 deletions includes/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function __construct( $namespace, $title, Config &$config ) {
// to detect whole words containing non-ASCII characters as well.
// Note that this requires a PCRE library that was compiled with
// --enable-unicode-properties
( $config->wordStartOnly ) ? $this->wordStart = '(?<!\pL)' : $this->wordStart = '';
( $config->wordEndOnly ) ? $this->wordEnd = '(?!\pL)' : $this->wordEnd = '';
( $config->wordStartOnly ) ? $this->wordStart = '(?<!\pL|\pN)' : $this->wordStart = '';
( $config->wordEndOnly ) ? $this->wordEnd = '(?!\pL|\pN)' : $this->wordEnd = '';
}

/**
Expand Down
38 changes: 38 additions & 0 deletions tests/phpunit/LinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,44 @@ public function addDBData() {
parent::addDBDataOnce(); // call parent after adding page to have targets invalidated
}

/**
* @dataProvider provideTestTitleWithNumberData
*/
public function testTitleWithNumber( $input, $expectedOutput ) {
$config = new LinkTitles\Config();
$config->wordStartOnly = true;
$config->wordEndOnly = true;
$this->insertPage( 'numbered-1', 'This page serves as a link target with a numbered title' );
$this->insertPage( 'numbered-101', 'This page serves as a link target with a numbered title' );
parent::addDBDataOnce(); // call parent after adding page to have targets invalidated
$source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
$linker = new LinkTitles\Linker( $config );
$result = $linker->linkContent( $source );
if ( !$result ) { $result = $input; }
$this->assertSame( $expectedOutput, $result );
}

public function provideTestTitleWithNumberData() {
return [
[
"Page text with numbered-1 in it.",
"Page text with [[numbered-1]] in it.",
],
[
"Page text with numbered-101 in it.",
"Page text with [[numbered-101]] in it.",
],
[
"Page text with numbered-1010 in it.",
"Page text with numbered-1010 in it.",
],
[
"Page text with link target1 in it.",
"Page text with link target1 in it.",
],
];
}

/**
* @dataProvider provideLinkContentTemplatesData
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/TargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testTargetWordStartOnly( $enabled, $delimiter ) {

public static function provideStartOnly() {
return [
[ true, '(?<!\pL)' ],
[ true, '(?<!\pL|\pN)' ],
[ false, '' ]
];
}
Expand All @@ -54,7 +54,7 @@ public function testTargetWordEndOnly( $enabled, $delimiter ) {

public static function provideEndOnly() {
return [
[ true, '(?!\pL)' ],
[ true, '(?!\pL|\pN)' ],
[ false, '' ]
];
}
Expand Down

0 comments on commit ce50459

Please sign in to comment.