$i = $lengthText;
} else {
// Search backwards for leading whitespace
- $wsStart = $i ? ( $i - strspn( $revText, ' ', $lengthText - $i ) ) : 0;
+ $wsStart = $i ? ( $i - strspn( $revText, " \t", $lengthText - $i ) ) : 0;
// Search forwards for trailing whitespace
// $wsEnd will be the position of the last space (or the '>' if there's none)
- $wsEnd = $endPos + 2 + strspn( $text, ' ', $endPos + 3 );
+ $wsEnd = $endPos + 2 + strspn( $text, " \t", $endPos + 3 );
// Keep looking forward as long as we're finding more
// comments.
if ( $c === false ) {
break;
}
- $c = $c + 2 + strspn( $text, ' ', $c + 3 );
+ $c = $c + 2 + strspn( $text, " \t", $c + 3 );
$comments[] = array( $wsEnd + 1, $c );
$wsEnd = $c;
}
// Remove leading whitespace from the end of the accumulator
// Sanity check first though
$wsLength = $i - $wsStart;
- if ( $wsLength > 0 && substr( $accum, -$wsLength ) === str_repeat( ' ', $wsLength ) ) {
+ if ( $wsLength > 0
+ && strspn( $accum, " \t", -$wsLength ) === $wsLength )
+ {
$accum = substr( $accum, 0, -$wsLength );
}
$i = $lengthText;
} else {
// Search backwards for leading whitespace
- $wsStart = $i ? ( $i - strspn( $revText, ' ', $lengthText - $i ) ) : 0;
+ $wsStart = $i ? ( $i - strspn( $revText, " \t", $lengthText - $i ) ) : 0;
// Search forwards for trailing whitespace
// $wsEnd will be the position of the last space (or the '>' if there's none)
- $wsEnd = $endPos + 2 + strspn( $text, ' ', $endPos + 3 );
+ $wsEnd = $endPos + 2 + strspn( $text, " \t", $endPos + 3 );
// Keep looking forward as long as we're finding more
// comments.
if ( $c === false ) {
break;
}
- $c = $c + 2 + strspn( $text, ' ', $c + 3 );
+ $c = $c + 2 + strspn( $text, " \t", $c + 3 );
$comments[] = array( $wsEnd + 1, $c );
$wsEnd = $c;
}
$wsLength = $i - $wsStart;
if ( $wsLength > 0
&& $accum->lastNode instanceof PPNode_Hash_Text
- && substr( $accum->lastNode->value, -$wsLength ) === str_repeat( ' ', $wsLength ) )
+ && strspn( $accum->lastNode->value, " \t", -$wsLength ) === $wsLength )
{
$accum->lastNode->value = substr( $accum->lastNode->value, 0, -$wsLength );
}
!!end
!!test
-Single-comment whitespace lines dont break lists, and so do multi-comment whitespace lines
+Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
!!input
*a
<!--This line will NOT split the list-->
!!end
+!!test
+Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
+!!input
+*a
+<!--This line will NOT split the list-->
+*b
+ <!--This line will NOT split the list either-->
+*c
+ <!--foo--> <!----> <!--This line NOT split the list
+ either-->
+*d
+!!result
+<ul><li>a
+</li><li>b
+</li><li>c
+</li><li>d
+</li></ul>
+
+!!end
+
!!test
Test the li-hack
(Cannot test this with PHP parser since it relies on Tidy for the hack)
array( "== h == <!--c1--> <!--c2--><!--c3--> ", "<root><h level=\"2\" i=\"1\">== h == <comment><!--c1--></comment> <comment><!--c2--></comment><comment><!--c3--></comment> </h></root>" ),
array( "== h == <!--c1--><!--c2--> <!--c3--> ", "<root><h level=\"2\" i=\"1\">== h == <comment><!--c1--></comment><comment><!--c2--></comment> <comment><!--c3--></comment> </h></root>" ),
array( "== h == <!--c1--> <!--c2--> <!--c3--> ", "<root><h level=\"2\" i=\"1\">== h == <comment><!--c1--></comment> <comment><!--c2--></comment> <comment><!--c3--></comment> </h></root>" ),
+ array( "== h ==<!--c1--> <!--c2-->", "<root><h level=\"2\" i=\"1\">== h ==<comment><!--c1--></comment> <comment><!--c2--></comment></h></root>" ),
+ array( "== h == <!--c1--> <!--c2-->", "<root><h level=\"2\" i=\"1\">== h == <comment><!--c1--></comment> <comment><!--c2--></comment></h></root>" ),
+ array( "== h ==<!--c1--> <!--c2--> ", "<root><h level=\"2\" i=\"1\">== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> </h></root>" ),
/* These are not working: */
- array( "== h ==<!--c1--> <!--c2-->", "<root>== h ==<comment><!--c1--></comment> <comment><!--c2--></comment></root>" ),
- array( "== h == <!--c1--> <!--c2-->", "<root>== h == <comment><!--c1--></comment> <comment><!--c2--></comment></root>" ),
- array( "== h ==<!--c1--> <!--c2--> ", "<root>== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> </root>" ),
array( "== h == x <!--c1--><!--c2--><!--c3--> ", "<root>== h == x <comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> </root>" ),
array( "== h ==<!--c1--> x <!--c2--><!--c3--> ", "<root>== h ==<comment><!--c1--></comment> x <comment><!--c2--></comment><comment><!--c3--></comment> </root>" ),
array( "== h ==<!--c1--><!--c2--><!--c3--> x ", "<root>== h ==<comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> x </root>" ),