# The parsoid-compatible option below is only relevant when we are running
# parser tests in integrated mode with Parsoid. This option is ignored
# when this test file is run with Parsoid in standalone mode.
!! options
parsoid-compatible=wt2html,wt2wt
version=2
!! end

!! article
Template:1x
!! text
{{{1}}}
!! endarticle

!! test
Blank input
!! wikitext
!! html
!! end

!! test
Simple paragraph
!! wikitext
This is a simple paragraph.
!! html
<p>This is a simple paragraph.
</p>
!! end

!! test
Paragraphs with extra newline spacing
!! wikitext
a

b (+2 nls)


c (+3 nls)



d (+4 nls)




e (+5 nls)
!! html
<p>a
</p><p>b (+2 nls)
</p><p><br />
c (+3 nls)
</p><p><br />
</p><p>d (+4 nls)
</p><p><br />
</p><p><br />
e (+5 nls)
</p>
!! end

!! test
Paragraphs with newline spacing with comment lines in between
!! wikitext
----
a
<!--foo-->
b
----
a
<!--foo--><!--More than 1 comment, still stripped-->
b
----
a
 <!--foo--> <!----> <!-- bar --> 
b
----
a
<!--foo-->

b
----
a

<!--foo-->
b
----
a
<!--foo-->


b
----
a


<!--foo-->
b
----
!! html
<hr />
<p>a
b
</p>
<hr />
<p>a
b
</p>
<hr />
<p>a
b
</p>
<hr />
<p>a
</p><p>b
</p>
<hr />
<p>a
</p><p>b
</p>
<hr />
<p>a
</p><p><br />
b
</p>
<hr />
<p>a
</p><p><br />
b
</p>
<hr />
!! end

!! test
Paragraphs with newline spacing with non-empty white-space lines in between
!! wikitext
----
a
 
b
----
a
 
 
b
----
!! html
<hr />
<p>a
</p><p>b
</p>
<hr />
<p>a
</p><p><br /> 
b
</p>
<hr />
!! end

!! test
Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
!! wikitext
----
a
 <!--foo-->
b
----
a
 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
b
----
a
 
<!--foo-->
 <!--bar-->
b
----
a
 
 <!--foo-->
 <!--bar-->
 
b
----
!! html
<hr />
<p>a
b
</p>
<hr />
<p>a
b
</p>
<hr />
<p>a
</p><p>b
</p>
<hr />
<p>a
</p><p><br /> 
b
</p>
<hr />
!! end

!! test
Extra newlines: More paragraphs with indented comment
!! wikitext
a

   <!--boo-->

b
!! html
<p>a
</p><p><br />
b
</p>
!!end

!! test
Extra new lines before and after lists are preserved
!! wikitext
a


*b


c
!! html/php
<p>a
</p><p><br />
</p>
<ul><li>b</li></ul>
<p><br />
c
</p>
!! html/parsoid
<p>a</p>
<p>
<br></p>
<ul><li>b</li></ul>
<p>
<br>
c</p>
!! end

# Parsoid regression test
!!test
Multiple newlines after tables are converted to p-br-p tags
!!options
parsoid=wt2html,wt2wt
!!wikitext
{|
|x
|}




=b=
!!html/php
<table>
<tbody><tr>
<td>x
</td></tr></tbody></table>
<p><br />
</p><p><br />
</p>
<div class="mw-heading mw-heading1"><h1 id="b">b</h1><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></div>
!!html/parsoid
<table>
<tbody>
<tr>
<td>x</td>
</tr>
</tbody>
</table>
<p><br/></p>
<p><br/></p>
<h1 id="b">b</h1>
!!end

!! test
No block tags
!! wikitext
a

b
!! html
<p>a
</p><p>b
</p>
!! end

!! test
Block tag on one line (<div>)
!! wikitext
a <div>foo</div>

b
!! html
<p>a </p><div>foo</div>
<p>b
</p>
!! end

!! test
No p-wrappable content
!! options
parsoid=wt2html,html2html
!! wikitext
<span><div>x</div></span>
<span><s><div>x</div></s></span>
<small><em></em></small><span><s><div>x</div></s></span>
!! html
<span><div>x</div></span>
<span><s><div>x</div></s></span>
<p><small><em></em></small></p><span><s><div>x</div></s></span>
!! end

# T177612: Parsoid-only test
!! test
Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
!! wikitext
{{1x|<span><div>x</div></span>}}
x
!! html/parsoid
<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
<p>x</p>
!! end

!! test
Block tag on one line (<blockquote>)
!! wikitext
a <blockquote>foo</blockquote>

b
!! html
<p>a </p><blockquote><p>foo</p></blockquote>
<p>b
</p>
!! end

!! test
Block tag on both lines (<div>)
!! wikitext
a <div>foo</div>

b <div>foo</div>
!! html
<p>a </p><div>foo</div><p>
b </p><div>foo</div>
!! end

!! test
Block tag on both lines (<blockquote>)
!! wikitext
a <blockquote>foo</blockquote>

b <blockquote>foo</blockquote>
!! html
<p>a </p><blockquote><p>foo</p></blockquote><p>
b </p><blockquote><p>foo</p></blockquote>
!! end

!! test
Multiple lines without block tags
!! wikitext
<div>foo</div> a
b
c
d<!--foo--> e
x <div>foo</div> z
!! html/php
<div>foo</div><p> a
</p><p>b
c
d e
</p><p>
x </p><div>foo</div><p> z</p>
!! html/parsoid
<div data-parsoid='{"stx":"html"}'>foo</div><p> a</p>
<p>b
c
d<!--foo--> e</p>
<p>x </p><div data-parsoid='{"stx":"html"}'>foo</div><p> z</p>
!! end

!! test
Empty lines between lines with block tags
!! wikitext
<div></div>


<div></div>a

b
<div>a</div>b

<div>b</div>d


<div>e</div>
!! html/php
<div></div>
<p><br />
</p>
<div></div><p>a
</p><p>b
</p>
<div>a</div><p>b
</p><div>b</div><p>d
</p><p><br />
</p>
<div>e</div>
!! html/parsoid
<div data-parsoid='{"stx":"html"}'></div>

<p><br /></p>
<div data-parsoid='{"stx":"html"}'></div><p>a</p>

<p>b</p>
<div data-parsoid='{"stx":"html"}'>a</div><p>b</p>

<div data-parsoid='{"stx":"html"}'>b</div><p>d</p>

<p><br /></p>
<div data-parsoid='{"stx":"html"}'>e</div>
!! end

!! test
Unclosed HTML p-tags should be handled properly
!! wikitext
<div><p>foo</div>
a

b
!! html/php
<div><p>foo</p></div>
<p>a
</p><p>b
</p>
!! html/parsoid
<div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
<p>a</p>
<p>b</p>
!! end

## SSS FIXME: I can come up with other scenarios where this doesn't work because
## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
## them for now.
!! test
1. P-wrapping should leave sol-transparent tags outside p-tags where possible
!! options
parsoid=wt2html
!! wikitext
a [[Category:A1]] [[Category:A2]]
[[Category:A3]]
[[Category:A4]]
!! html/parsoid
<p>a</p>
<link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
!! end

!! test
2. P-wrapping should leave sol-transparent tags outside p-tags where possible
!! options
parsoid=wt2html
!! wikitext
[[Category:A1]]a
!! html/parsoid
<link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
!! end

!! test
No paragraph necessary for SOL transparent template
!! wikitext
<span><div>foo</div></span>
[[Category:Foo]]

<span><div>foo</div></span>
{{1x|[[Category:Foo]]}}
!! html/php
<span><div>foo</div></span>
<span><div>foo</div></span>
!! html/parsoid
<span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
<link rel="mw:PageProp/Category" href="./Category:Foo"/>

<span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
<span class="mw-empty-elt" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'><link rel="mw:PageProp/Category" href="./Category:Foo"/></span>
!! end

!! test
Avoid expanding multiline sol transparent template ranges unnecessarily
!! wikitext
hi


{{1x|<br/>
}}

[[Category:Ho]]
!! html/php
<p>hi
</p><p><br />
<br />
</p>
!! html/parsoid
<p>hi</p>

<p><br />
<br about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
</span></p>

<link rel="mw:PageProp/Category" href="./Category:Ho" />
!! end

!! test
Paragraph wrapping following unclosed table
!! options
parsoid=wt2html,html2html
!! wikitext
{|
|-

{|
| x
|}

a

b

c
!! html/php
<table>


</table><table>
<tbody><tr>
<td>x
</td></tr></tbody></table>
<p>a
</p><p>b
</p><p>c
</p>
!! html/parsoid
<table data-parsoid='{"autoInsertedEnd":true}'>
<tbody class="mw-empty-elt"><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>

</tbody></table><table>
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
</tbody></table>

<p>a</p>

<p>b</p>

<p>c</p>
!! end

!! test
Paragraph wrapping suppressed in html p
!! options
parsoid=wt2html,html2html
!! wikitext
<p>


hi



</p>
!! html/php
<p>


hi



</p>
!! html/parsoid
<p data-parsoid='{"stx":"html"}'>


hi



</p>
!! end

!! test
Dangling table row doesn't prevent p-wrapping
!! options
parsoid=wt2html,html2html
!! wikitext
{|
| hi
|-
|} ho
!! html/parsoid
<table>
<tbody><tr><td>hi</td></tr>
<tr class="mw-empty-elt"></tr>
</tbody></table><p> ho</p>
!! end

!! test
P-wrapping non-breaking spaces
!! wikitext
 
!! html/php
<p>&#160;
</p>
!! html/parsoid
<p> </p>
!! end

!! test
Paragraph wrapping suppressed in table captions
!! wikitext
{|
|+hi
|ho
|}

{|
|hi
|+ho
|}

it's off to work we go
!! html/php
<table>
<caption>hi
</caption>
<tbody><tr>
<td>ho
</td></tr></tbody></table>
<table>
<tbody><tr>
<td>hi
</td>
</tr></tbody><caption>ho
</caption></table>
<p>it's off to work we go
</p>
!! html/parsoid
<table>
<caption>hi</caption>
<tbody><tr><td>ho</td></tr>
</tbody></table>

<table>
<tbody><tr><td>hi</td></tr>
</tbody><caption>ho</caption>
</table>

<p>it's off to work we go</p>
!! end

!! test
Extlink on a line with a block gets wrapped
!! wikitext
[https://google.com {{1x|foo}}] bar <div>foo</div>
!! html/php
<p><a rel="nofollow" class="external text" href="https://google.com">foo</a> bar </p><div>foo</div>
!! html/parsoid
<p><a rel="mw:ExtLink nofollow" href="https://google.com" class="external text"><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span></a> bar </p><div data-parsoid='{"stx":"html"}'>foo</div>
!! end

!! test
1. TD content in tables nested in dl-lists should get p-wrapped
!! options
parsoid=wt2html
!! wikitext
:{|
|foo
bar
|}

:::{|
|foo
bar
|}
!! html
<dl><dd><table>
<tbody><tr>
<td>foo
<p>bar
</p>
</td></tr></tbody></table></dd></dl>
<dl><dd><dl><dd><dl><dd><table>
<tbody><tr>
<td>foo
<p>bar
</p>
</td></tr></tbody></table></dd></dl></dd></dl></dd></dl>
!! end

# Parsoid combines dl-lists whereas legacy doesn't
!! test
2. TD content in tables nested in dl-lists should get p-wrapped
!! options
parsoid=wt2html
!! wikitext
:a
:{|
|foo
bar
|}
:*b
:::{|
|foo
bar
|}
!! html/php
<dl><dd>a</dd></dl>
<dl><dd><table>
<tbody><tr>
<td>foo
<p>bar
</p>
</td></tr></tbody></table></dd></dl>
<dl><dd><ul><li>b</li></ul></dd></dl>
<dl><dd><dl><dd><dl><dd><table>
<tbody><tr>
<td>foo
<p>bar
</p>
</td></tr></tbody></table></dd></dl></dd></dl></dd></dl>
!! html/parsoid
<dl><dd>a</dd>
<dd><table>
<tbody><tr><td>foo
<p>bar</p></td></tr>
</tbody></table>
<ul><li>b</li></ul>
<dl><dd><dl><dd><table>
<tbody><tr><td>foo
<p>bar</p></td></tr>
</tbody></table></dd></dl></dd></dl></dd></dl>
!! end

!! test
T8200: blockquotes and paragraph formatting
!! wikitext
<blockquote>
foo
</blockquote>

bar

 baz
!! html
<blockquote>
<p>foo
</p>
</blockquote>
<p>bar
</p>
<pre>baz
</pre>
!! end

!! test
T53086: Double newlines in blockquotes should be turned into paragraphs
!! wikitext
<blockquote>
Foo

Bar
</blockquote>
!! html
<blockquote>
<p>Foo
</p><p>Bar
</p>
</blockquote>
!! end

!! test
T17491: <ins>/<del> in blockquote
!! wikitext
<blockquote>
Foo <del>bar</del> <ins>baz</ins> quux
</blockquote>
!! html
<blockquote>
<p>Foo <del>bar</del> <ins>baz</ins> quux
</p>
</blockquote>
!! end

!! test
T17491: <ins>/<del> in blockquote (2)
!! wikitext
<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
</blockquote>
!! html
<blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
</p></blockquote>
!! end

!! test
T10293: Use of center tag ruins paragraph formatting
!! wikitext
<center>
foo
</center>

bar

 baz
!! html
<center>
<p>foo
</p>
</center>
<p>bar
</p>
<pre>baz
</pre>
!! end

!! test
Paragraphs inside divs (no extra line breaks)
!! wikitext
<div>Line one

Line two</div>
!! html
<div>Line one
Line two</div>
!! end

!! test
Paragraphs inside divs (extra line break on open)
!! wikitext
<div>
Line one

Line two</div>
!! html
<div>
<p>Line one
</p>
Line two</div>
!! end

!! test
Paragraphs inside divs (extra line break on close)
!! wikitext
<div>Line one

Line two
</div>
!! html
<div>Line one
<p>Line two
</p>
</div>
!! end

!! test
Paragraphs inside divs (extra line break on open and close)
!! wikitext
<div>
Line one

Line two
</div>
!! html
<div>
<p>Line one
</p><p>Line two
</p>
</div>
!! end

# doBlockLevels screws up this output and Remex cleans up as much as it can.
!! test
Nesting tags, paragraphs on lines which begin with <div>
!! wikitext
<div></div><strong>A
B</strong>
!! html/php
<div></div><p><strong>A
</strong></p><strong></strong><p><strong>B</strong>
</p>
!! html/parsoid
<div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
<p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
!! end

# T8200: <blockquote> should behave like <div> with respect to line breaks
!! test
T8200: paragraphs inside blockquotes (no extra line breaks)
!! wikitext
<blockquote>Line one

Line two</blockquote>
!! html
<blockquote><p>Line one
Line two</p></blockquote>
!! end

!! test
T8200: paragraphs inside blockquotes (extra line break on open)
!! wikitext
<blockquote>
Line one

Line two</blockquote>
!! html
<blockquote>
<p>Line one
</p><p>
Line two</p></blockquote>
!! end

!! test
T8200: paragraphs inside blockquotes (extra line break on close)
!! wikitext
<blockquote>Line one

Line two
</blockquote>
!! html
<blockquote><p>Line one
</p><p>Line two
</p>
</blockquote>
!! end

!! test
T8200: paragraphs inside blockquotes (extra line break on open and close)
!! wikitext
<blockquote>
Line one

Line two
</blockquote>
!! html
<blockquote>
<p>Line one
</p><p>Line two
</p>
</blockquote>
!! end

## This is a corner case interaction between the paragraph wrapping in the
## php parser's BlockLevelPass and Remex.  `doBlockLevels` has a notion of
## some tags which close paragraphs (and thus prevent wrapping on their line),
## of which "div" is one, but do p-wrapping inside them.  These are referred
## to as "never suppressing".  Remex, for its part, doesn't traverse into
## "div"s to p-wrap.  Hence, we only get this partial wrapping.
!! test
Paragraphs inside blockquotes/divs (no extra line breaks)
!! wikitext
<blockquote><div>Line one

Line two</div></blockquote>
!! html
<blockquote><div>Line one
Line two</div></blockquote>
!! end

!! test
Paragraphs inside blockquotes/divs (extra line break on open)
!! wikitext
<blockquote><div>
Line one

Line two</div></blockquote>
!! html
<blockquote><div>
<p>Line one
</p>
Line two</div></blockquote>
!! end

!! test
Paragraphs inside blockquotes/divs (extra line break on close)
!! wikitext
<blockquote><div>Line one

Line two
</div></blockquote>
!! html
<blockquote><div>Line one
<p>Line two
</p>
</div></blockquote>
!! end

!! test
Paragraphs inside blockquotes/divs (extra line break on open and close)
!! wikitext
<blockquote><div>
Line one

Line two
</div></blockquote>
!! html
<blockquote><div>
<p>Line one
</p><p>Line two
</p>
</div></blockquote>
!! end

# Regression test to prevent problematic simplifications of parser tests
!! test
Don't paragraph-wrap empty newlines between HTML list items
!! options
parsoid=wt2html
!! wikitext
<ol>
<li>foo</li>



<li>foo</li>
</ol>
!! html/php
<ol>
<li>foo</li>



<li>foo</li>
</ol>
!! html/parsoid
<ol data-parsoid='{"stx":"html"}'>
<li data-parsoid='{"stx":"html"}'>foo</li>



<li data-parsoid='{"stx":"html"}'>foo</li>
</ol>
!! end

!! test
Nowikis can be considered pwrap optional based on content
!! wikitext
{{1x|<nowiki />[[category:123]]<div>123</div>}}
!! html/php
<div>123</div>
!! html/parsoid
<span typeof="mw:Nowiki mw:Transclusion" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;nowiki />[[category:123]]&lt;div>123&lt;/div>"}},"i":0}}]}'></span><link rel="mw:PageProp/Category" href="./Category:123" about="#mwt1"/><div about="#mwt1" data-parsoid='{"stx":"html"}'>123</div>
!! end

!! test
Multiple newlines in between HTML list items don't induce paragraph wrapping
!! wikitext
<ul>
<li>hi</li>




<li>ho</li>
</ul>

<dl>
<dt>hi</dt>
<dd>ho<div>123</div>
</dd>


</dl>
!! html/php
<ul>
<li>hi</li>




<li>ho</li>
</ul>
<dl>
<dt>hi</dt>
<dd>ho<div>123</div>
</dd>


</dl>
!! end

## Currently the p-wrapper is fragile in how it adds / removes transformations.
## Having nested or stray pre tags results in the attempt to add duplicates,
## causing an assertion fail. This test tries to prevent that situation.
!! test
Ensure ParagraphWrapper can deal with stray closing pre tags
!! options
parsoid=wt2html
!! wikitext
plain text</pre>
!! html/parsoid
<p>plain text</p>
!! end

## Right now, Parsoid doesn't de-duplicate style tags.
## So, we shouldn't see link tags that need to bypass the sanitizer.
## In a followup patch, when we de-duplicate style tags and
## introduce link tags, we'll add a hook for link tags in
## the parser test runner script.
!! test
Validating that <style> isn't wrapped in a paragraph (T186965)
!! options
styletag=1
!! wikitext
A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph

<style>.foo::before { content: "<foo>"; }</style>

<style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>

But if it's on a line with other content, let it be wrapped.

<style>.foo::before { content: "<foo>"; }</style> bar

foo <style>.foo::before { content: "<foo>"; }</style>

foo <style>.foo::before { content: "<foo>"; }</style> bar

And the same if we have non-paragraph-breaking whitespace

foo
<style>.foo::before { content: "<foo>"; }</style>
bar
!! html/php
<p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
</p>
<style>.foo::before { content: "<foo>"; }</style>
<style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar" /><style>.foo::before { content: "<foo>"; }</style>
<p>But if it's on a line with other content, let it be wrapped.
</p><p><style>.foo::before { content: "<foo>"; }</style> bar
</p><p>foo <style>.foo::before { content: "<foo>"; }</style>
</p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
</p><p>And the same if we have non-paragraph-breaking whitespace
</p><p>foo
<style>.foo::before { content: "<foo>"; }</style>
bar
</p>
!! html/parsoid
<p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>

<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>

<p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> &lt;link rel="foo" href="bar"/><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>

<p>But if it's on a line with other content, let it be wrapped.</p>

<p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>

<p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>

<p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>

<p>And the same if we have non-paragraph-breaking whitespace</p>

<p>foo
<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
bar</p>
!! end

!! test
Validating that <link> isn't wrapped in a paragraph (T186965)
!! options
styletag=1
!! wikitext
A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph

<link rel="foo" href="bar"/>

<link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>

But if it's on a line with other content, let it be wrapped.

<link rel="foo" href="bar"/> bar

foo <link rel="foo" href="bar"/>

foo <link rel="foo" href="bar"/> bar

And the same if we have non-paragraph-breaking whitespace

foo
<link rel="foo" href="bar"/>
bar
!! html/php
<p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
</p>
<link rel="foo" href="bar" />
<link rel="foo" href="bar" /> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar" />
<p>But if it's on a line with other content, let it be wrapped.
</p><p><link rel="foo" href="bar" /> bar
</p><p>foo <link rel="foo" href="bar" />
</p><p>foo <link rel="foo" href="bar" /> bar
</p><p>And the same if we have non-paragraph-breaking whitespace
</p><p>foo
<link rel="foo" href="bar" />
bar
</p>
!! end

!! test
P-wrapping should not break after <td>s separated by newlines are converted back to pipes
!! wikitext
a
|b

|c
d
!! html/php
<p>a
|b
</p><p>|c
d
</p>
!! html/parsoid
<p>a
|b</p>

<p>|c
d</p>
!! end

# BlockLevelPass suppresses P-wrapping for tags whose names begin with
# `mw:`.  We'll somewhat arbitrarily chose `mw:editsection` to
# represent this class of tags for testing purposes.
!! test
Tags which are hidden from tidiers cannot pass through the Sanitizer
!! options
parsoid=wt2html,html2html
!! wikitext
<mw:editsection><script>alert();</script></mw:editsection>

<meta property="mw:PageProp/toc" />
!! html/php
<p>&lt;mw:editsection&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:editsection&gt;
</p><p>&lt;meta property="mw:PageProp/toc" /&gt;
</p>
!! html/parsoid
<p>&lt;mw:editsection>&lt;script>alert();&lt;/script>&lt;/mw:editsection></p>

<p>&lt;meta property="mw:PageProp/toc" /></p>
!! end

!! test
T386233: suppress <nowiki/> tags between extension tags
!! wikitext
Deliberately unclosed b tag triggers p-wrapping if a nowiki span is
added between the divtags:

<b>{{1x|<divtag>abc</divtag><divtag>xyz</divtag>}}
!! html/php
<p>Deliberately unclosed b tag triggers p-wrapping if a nowiki span is
added between the divtags:
</p>
<b><div>abc</div><div>xyz</div></b>
!! html/parsoid+integrated
<p>Deliberately unclosed b tag triggers p-wrapping if a nowiki span is added between the divtags:</p>
<b>
<div typeof="mw:Extension/divtag mw:Transclusion" data-mw='{"name":"divtag","attrs":{},"body":{"extsrc":"abc"},"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;divtag>abc&lt;/divtag>&lt;divtag>xyz&lt;/divtag>"}},"i":0}}]}'>
<p>abc</p>
</div>
<div typeof="mw:Extension/divtag" data-mw='{"name":"divtag","attrs":{},"body":{"extsrc":"xyz"}}'>
<p>xyz</p>
</div>
</b>
!! end
