Eflyjason has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/397785 )
Change subject: Missing whitespaces in WikiTextStructure
......................................................................
Missing whitespaces in WikiTextStructure
Bug: T182667
Change-Id: Ida5601daabe153f2992d341500b1de1310bc2506
---
M includes/content/WikiTextStructure.php
M tests/phpunit/includes/content/WikitextStructureTest.php
2 files changed, 14 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/85/397785/1
diff --git a/includes/content/WikiTextStructure.php
b/includes/content/WikiTextStructure.php
index 0eadc3c..9da696f 100644
--- a/includes/content/WikiTextStructure.php
+++ b/includes/content/WikiTextStructure.php
@@ -174,10 +174,15 @@
// preferred in highlighting.
$formatter->remove( $this->auxiliaryElementSelectors );
$auxiliaryElements = $formatter->filterContent();
- $this->allText = trim( Sanitizer::stripAllTags(
$formatter->getText() ) );
+ // preg_replace: T182667
+ $this->allText = trim( Sanitizer::stripAllTags(
+ preg_replace('/<\/? *div[^>]*>/i', ' ',
$formatter->getText() )
+ ) );
foreach ( $auxiliaryElements as $auxiliaryElement ) {
$this->auxText[] =
- trim( Sanitizer::stripAllTags(
$formatter->getText( $auxiliaryElement ) ) );
+ trim( Sanitizer::stripAllTags(
+ preg_replace('/<\/(th|td|caption)>/i',
' </$1>', $formatter->getText( $auxiliaryElement ) )
+ ) );
}
}
diff --git a/tests/phpunit/includes/content/WikitextStructureTest.php
b/tests/phpunit/includes/content/WikitextStructureTest.php
index f1b54f6..d3927ca 100644
--- a/tests/phpunit/includes/content/WikitextStructureTest.php
+++ b/tests/phpunit/includes/content/WikitextStructureTest.php
@@ -87,6 +87,10 @@
Opening text is opening.
== Then comes header ==
Then we got more<br>text
+== Another header ==
+foo<div>bar</div>baz
+
+a<i>b</i>c
=== And more headers ===
{| class="wikitable"
|-
@@ -99,9 +103,10 @@
END;
$struct = $this->getStructure( $text );
$this->assertEquals( "Opening text is opening.",
$struct->getOpeningText() );
- $this->assertEquals( "Opening text is opening. Then we got
more text",
+ $this->assertEquals( "Opening text is opening. Then we got
more text foo bar baz abc",
$struct->getMainText() );
- $this->assertEquals( [ "Header table row in table another row
in table" ],
+ // TODO: Remove extra spaces after T182074 is fixed
+ $this->assertEquals( [ "Header table row in table another
row in table" ],
$struct->getAuxiliaryText() );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/397785
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida5601daabe153f2992d341500b1de1310bc2506
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Eflyjason <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits