Pppery has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/394232 )
Change subject: Re-enable
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment sniff
......................................................................
Re-enable MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment sniff
Bug: T170580
Change-Id: Ib5bcab3414f44013cf57c0d006b212dea175473a
---
M .phpcs.xml
M includes/ExtractFormatter.php
M tests/phpunit/ExtractFormatterTest.php
3 files changed, 18 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts
refs/changes/32/394232/1
diff --git a/.phpcs.xml b/.phpcs.xml
index af73563..b118481 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -4,7 +4,6 @@
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude
name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
- <exclude
name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>
<file>.</file>
<arg name="extensions" value="php,php5,inc" />
diff --git a/includes/ExtractFormatter.php b/includes/ExtractFormatter.php
index f1d5f0a..b3c94a4 100644
--- a/includes/ExtractFormatter.php
+++ b/includes/ExtractFormatter.php
@@ -54,9 +54,12 @@
$text = parent::getText();
if ( $this->plainText ) {
$text = html_entity_decode( $text );
- $text = str_replace( "\xC2\xA0", ' ', $text ); //
replace nbsp with space
- $text = str_replace( "\r", "\n", $text ); // for Windows
- $text = preg_replace( "/\n{3,}/", "\n\n", $text ); //
normalise newlines
+ // replace nbsp with space
+ $text = str_replace( "\xC2\xA0", ' ', $text );
+ // for Windows
+ $text = str_replace( "\r", "\n", $text );
+ // normalise newlines
+ $text = preg_replace( "/\n{3,}/", "\n\n", $text );
}
return $text;
}
@@ -85,10 +88,14 @@
// Based on code from OpenSearchXml by Brion Vibber
$endchars = [
- '[^\p{Lu}]\.(?:[ \n]|$)', '[\!\?](?:[ \n]|$)', //
regular ASCII
- '。', // full-width ideographic full-stop
- '.', '!', '?', // double-width roman forms
- '。', // half-width ideographic full stop
+ // regular ASCII
+ '[^\p{Lu}]\.(?:[ \n]|$)', '[\!\?](?:[ \n]|$)',
+ // full-width ideographic full-stop
+ '。',
+ // double-width roman forms
+ '.', '!', '?',
+ // half-width ideographic full stop
+ '。',
];
$endgroup = implode( '|', $endchars );
diff --git a/tests/phpunit/ExtractFormatterTest.php
b/tests/phpunit/ExtractFormatterTest.php
index 6b0174f..26d5f50 100644
--- a/tests/phpunit/ExtractFormatterTest.php
+++ b/tests/phpunit/ExtractFormatterTest.php
@@ -19,7 +19,8 @@
$po->setEditSection( true );
$config =
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig(
'textextracts' );
$fmt = new ExtractFormatter( $text, $plainText, $config );
- $fmt->remove( '.metadata' ); // Will be added via
$wgExtractsRemoveClasses on WMF
+ // .metadata class will be added via $wgExtractsRemoveClasses
on WMF
+ $fmt->remove( '.metadata' );
$text = trim( $fmt->getText() );
$this->assertEquals( $expected, $text );
}
@@ -191,7 +192,8 @@
[ $text, 8, 'Lullzy lulz' ],
// HTML processing
[ $html, 1, 'foo' ],
- [ $html, 4, 'foo<tag>' ], // let HTML sanitizer clean
it up later
+ // let HTML sanitizer clean it up later
+ [ $html, 4, 'foo<tag>' ],
[ $html, 12, 'foo<tag>bar</tag>' ],
[ $html, 13, 'foo<tag>bar</tag>' ],
[ $html, 16, 'foo<tag>bar</tag>' ],
--
To view, visit https://gerrit.wikimedia.org/r/394232
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5bcab3414f44013cf57c0d006b212dea175473a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TextExtracts
Gerrit-Branch: master
Gerrit-Owner: Pppery <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits