Pppery has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/326365 )
Change subject: Make #lsth ignore blank line at end of section
......................................................................
Make #lsth ignore blank line at end of section
This means that an empty paragraph is not produced when an section
ending with a blank line transcludes another section ending with a blank
line at its end.
Bug: T144762
Change-Id: Id347c316aec18b41ed8bf331ca0465af8f05fa5c
---
M LabeledSectionTransclusion.class.php
M lsthParserTests.txt
2 files changed, 17 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LabeledSectionTransclusion
refs/changes/65/326365/1
diff --git a/LabeledSectionTransclusion.class.php
b/LabeledSectionTransclusion.class.php
index f4ae2c6..503b262 100644
--- a/LabeledSectionTransclusion.class.php
+++ b/LabeledSectionTransclusion.class.php
@@ -533,16 +533,16 @@
if ( $to != '' ) {
// if $to is supplied, try and match it. If we don't
match, just
// ignore it.
- $pat = '^(={1,6})\s*' . preg_quote( $to, '/' ) .
'\s*\1\s*$';
+ $pat = PHP_EOL . '{1,2}(={1,6})\s*' . preg_quote( $to,
'/' ) . '\s*\1\s*$';
if ( preg_match( "/$pat/im", $text, $m,
PREG_OFFSET_CAPTURE, $begin_off ) ) {
- $end_off = $m[0][1] -1;
+ $end_off = $m[0][1];
}
}
if ( !isset( $end_off ) ) {
- $pat = '^(={1,' . $head_len . '})(?!=).*?\1\s*$';
+ $pat = PHP_EOL . '{1,2}(={1,' . $head_len .
'})(?!=).*?\1\s*$';
if ( preg_match( "/$pat/im", $text, $m,
PREG_OFFSET_CAPTURE, $begin_off ) ) {
- $end_off = $m[0][1] -1;
+ $end_off = $m[0][1];
}
}
diff --git a/lsthParserTests.txt b/lsthParserTests.txt
index beff69f..11fc9d1 100644
--- a/lsthParserTests.txt
+++ b/lsthParserTests.txt
@@ -91,3 +91,16 @@
{{#lsth:LsthSections|9999}}
!!result
!!end
+
+!!test
+blank lines at end
+!!input
+{{#lsth:LsthSections|1}}
+
+== Another Section ==
+!!result
+<p>sec 1
+</p>
+<h2><span class="mw-headline" id="Another_Section">Another Section</span><span
class="mw-editsection"><span class="mw-editsection-bracket">[</span><a
href="/index.php?title=Parser_test&action=edit&section=1" title="Edit
section: Another Section">edit</a><span
class="mw-editsection-bracket">]</span></span></h2>
+
+!!end
--
To view, visit https://gerrit.wikimedia.org/r/326365
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id347c316aec18b41ed8bf331ca0465af8f05fa5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LabeledSectionTransclusion
Gerrit-Branch: master
Gerrit-Owner: Pppery <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits