Merge "Fix parsing of <pre> tags generated by extension tag hooks"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 4 Apr 2018 19:36:31 +0000 (19:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 4 Apr 2018 19:36:31 +0000 (19:36 +0000)
includes/parser/BlockLevelPass.php
tests/parser/parserTests.txt

index acdc652..1173dd2 100644 (file)
@@ -306,8 +306,12 @@ class BlockLevelPass {
 
                                if ( $openMatch || $closeMatch ) {
                                        $pendingPTag = false;
-                                       # @todo T7718: paragraph closed
-                                       $output .= $this->closeParagraph();
+                                       // Only close the paragraph if we're not inside a <pre> tag, or if
+                                       // that <pre> tag has just been opened
+                                       if ( !$this->inPre || $preOpenMatch ) {
+                                               // @todo T7718: paragraph closed
+                                               $output .= $this->closeParagraph();
+                                       }
                                        if ( $preOpenMatch && !$preCloseMatch ) {
                                                $this->inPre = true;
                                        }
index 0641e0b..05afefa 100644 (file)
@@ -18313,6 +18313,27 @@ this is a '''test'''
 <p>this is a <b>test</b></p>
 !! end
 
+!! test
+Parser hook: horizontal rule inside extension tag that outputs <pre>
+!! wikitext
+<tag>
+Hello
+<hr/>
+Goodbye
+</tag>
+!! html/php
+<pre>
+'
+Hello
+<hr/>
+Goodbye
+'
+array (
+)
+</pre>
+
+!! end
+
 ###
 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
 ###