mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 20:09:44 +00:00
XW-1429 | remove whitespace after original marker and put a single space after new marker position
This commit is contained in:
parent
bc7f3efb35
commit
3ef5a8e72b
|
@ -136,19 +136,9 @@ class PortableInfoboxParserTagController extends WikiaController {
|
|||
|
||||
// Skip if the first marker is already at the top
|
||||
if ( strpos( $text, $firstMarker ) !== 0 ) {
|
||||
$firstMarkerWithFollowingWhitespace = '';
|
||||
|
||||
$text = preg_replace_callback(
|
||||
'/(' . $firstMarker . ')\s*/',
|
||||
function ( $matches ) use ( &$firstMarkerWithFollowingWhitespace ) {
|
||||
$firstMarkerWithFollowingWhitespace = $matches[0];
|
||||
return '';
|
||||
},
|
||||
$text,
|
||||
1
|
||||
);
|
||||
|
||||
$text = $firstMarkerWithFollowingWhitespace . $text;
|
||||
// Remove first marker and the following whitespace
|
||||
$text = preg_replace( '/' . $firstMarker . '\s*/', '', $text, 1 );
|
||||
$text = $firstMarker . ' ' . $text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@ class PortableInfoboxParserTagControllerTest extends WikiaBaseTest {
|
|||
'infobox-1' => '1'
|
||||
],
|
||||
'text' => 'nospaceinfobox-1',
|
||||
'expected' => 'infobox-1nospace',
|
||||
'message' => 'no space between elements'
|
||||
'expected' => 'infobox-1 nospace',
|
||||
'message' => 'no space between input elements'
|
||||
],
|
||||
[
|
||||
'markers' => [
|
||||
|
@ -290,8 +290,7 @@ class PortableInfoboxParserTagControllerTest extends WikiaBaseTest {
|
|||
more text
|
||||
infobox-2
|
||||
and some more',
|
||||
'expected' => 'infobox-1
|
||||
some text
|
||||
'expected' => 'infobox-1 some text
|
||||
some more
|
||||
more text
|
||||
infobox-2
|
||||
|
|
Loading…
Reference in a new issue