2007-06-24 21:35:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setup()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
parent::setup();
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('AutoFormat.AutoParagraph', true);
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testSingleParagraph()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Foobar',
|
|
|
|
'<p>Foobar</p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testSingleMultiLineParagraph()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par 1
|
|
|
|
Par 1 still',
|
|
|
|
'<p>Par 1
|
|
|
|
Par 1 still</p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTwoParagraphs()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
|
|
|
Par2',
|
2008-08-10 04:32:29 +00:00
|
|
|
"<p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p>"
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTwoParagraphsWithLotsOfSpace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-24 21:35:34 +00:00
|
|
|
|
|
|
|
Par2',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTwoParagraphsWithInlineElements()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Par1</b>
|
|
|
|
|
|
|
|
<i>Par2</i>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p><b>Par1</b></p>
|
|
|
|
|
|
|
|
<p><i>Par2</i></p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testSingleParagraphThatLooksLikeTwo()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Par1
|
|
|
|
|
|
|
|
Par2</b>',
|
|
|
|
'<p><b>Par1
|
|
|
|
|
|
|
|
Par2</b></p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testAddParagraphAdjacentToParagraph()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1<p>Par2</p>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphUnclosedInlineElement()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Par1',
|
|
|
|
'<p><b>Par1</b></p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreservePreTags()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<pre>Par1
|
|
|
|
|
|
|
|
Par1</pre>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testIgnoreTrailingWhitespace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
|
|
|
',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testDoNotParagraphBlockElements()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
|
|
|
<div>Par2</div>
|
|
|
|
|
|
|
|
Par3',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<div>Par2</div>
|
|
|
|
|
|
|
|
<p>Par3</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphTextAndInlineNodes()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par<b>1</b>',
|
|
|
|
'<p>Par<b>1</b></p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveLeadingWhitespace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'
|
|
|
|
|
|
|
|
Par',
|
2008-08-10 04:32:29 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
<p>Par</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveSurroundingWhitespace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'
|
|
|
|
|
|
|
|
Par
|
|
|
|
|
|
|
|
',
|
2008-08-10 04:32:29 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
<p>Par</p>
|
|
|
|
|
|
|
|
'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphInsideBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>Par1
|
|
|
|
|
|
|
|
Par2</div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphInlineNodeInsideBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><b>Par1</b>
|
|
|
|
|
|
|
|
Par2</div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p><b>Par1</b></p>
|
|
|
|
|
|
|
|
<p>Par2</p></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNoParagraphWhenOnlyOneInsideBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult('<div>Par1</div>');
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphTwoInlineNodesInsideBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><b>Par1</b>
|
|
|
|
|
|
|
|
<i>Par2</i></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p><b>Par1</b></p>
|
|
|
|
|
|
|
|
<p><i>Par2</i></p></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testPreserveInlineNodesInPreTag()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<pre><b>Par1</b>
|
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
<i>Par2</i></pre>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testSplitUpInternalsOfPTagInBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><p>Foo
|
|
|
|
|
|
|
|
Bar</p></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p>Foo</p>
|
|
|
|
|
|
|
|
<p>Bar</p></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testSplitUpInlineNodesInPTagInBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><p><b>Foo</b>
|
|
|
|
|
|
|
|
<i>Bar</i></p></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p><b>Foo</b></p>
|
|
|
|
|
|
|
|
<p><i>Bar</i></p></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNoParagraphSingleInlineNodeInBlockNode()
|
|
|
|
{
|
2007-09-27 00:39:05 +00:00
|
|
|
$this->assertResult( '<div><b>Foo</b></div>' );
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphInBlockquote()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<blockquote>Par1
|
|
|
|
|
|
|
|
Par2</blockquote>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<blockquote><p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p></blockquote>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNoParagraphBetweenListItem()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<ul><li>Foo</li>
|
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
<li>Bar</li></ul>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphSingleElementWithSurroundingSpace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>
|
|
|
|
|
|
|
|
Bar
|
|
|
|
|
2008-12-06 07:28:20 +00:00
|
|
|
</div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div>
|
|
|
|
|
|
|
|
<p>Bar</p>
|
|
|
|
|
|
|
|
</div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testIgnoreExtraSpaceWithLeadingInlineNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>Par1</b>a
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-06 07:28:20 +00:00
|
|
|
Par2',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p><b>Par1</b>a</p>
|
|
|
|
|
|
|
|
<p>Par2</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testAbsorbExtraEndingPTag()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
2008-12-06 07:28:20 +00:00
|
|
|
Par2</p>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testAbsorbExtraEndingDivTag()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
2008-12-06 07:28:20 +00:00
|
|
|
Par2</div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<p>Par2</p>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testDoNotParagraphSingleSurroundingSpaceInBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>
|
|
|
|
Par1
|
2007-08-08 05:38:52 +00:00
|
|
|
</div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBlockNodeTextDelimeterInBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>Par1
|
|
|
|
|
|
|
|
<div>Par2</div></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p>Par1</p>
|
|
|
|
|
|
|
|
<div>Par2</div></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>Par1
|
2007-09-27 00:39:05 +00:00
|
|
|
<div>Par2</div></div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBlockNodeTextDelimeterWithoutDoublespace()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
<div>Par2</div>',
|
|
|
|
'<p>Par1
|
2008-08-10 04:32:29 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<div>Par2</div>'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTwoParagraphsOfTextAndInlineNode()
|
|
|
|
{
|
2007-06-26 15:07:07 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par1
|
|
|
|
|
|
|
|
<b>Par2</b>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<p>Par1</p>
|
|
|
|
|
|
|
|
<p><b>Par2</b></p>'
|
2007-06-26 15:07:07 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLeadingInlineNodeParagraph()
|
|
|
|
{
|
2007-06-29 00:24:59 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img /> Foo',
|
|
|
|
'<p><img /> Foo</p>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTrailingInlineNodeParagraph()
|
|
|
|
{
|
2007-06-29 03:57:14 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<li>Foo <a>bar</a></li>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTwoInlineNodeParagraph()
|
|
|
|
{
|
2007-06-29 03:57:14 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<li><b>baz</b><a>bar</a></li>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNoParagraphTrailingBlockNodeInBlockNode()
|
|
|
|
{
|
2007-06-29 03:57:14 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><div>asdf</div><b>asdf</b></div>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode()
|
|
|
|
{
|
2007-06-29 03:57:14 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><div>asdf</div>
|
|
|
|
|
|
|
|
<b>asdf</b></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><div>asdf</div>
|
|
|
|
|
|
|
|
<p><b>asdf</b></p></div>'
|
2007-06-29 03:57:14 +00:00
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParagraphTwoInlineNodesAndWhitespaceNode()
|
|
|
|
{
|
2007-06-29 17:48:56 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>One</b> <i>Two</i>',
|
|
|
|
'<p><b>One</b> <i>Two</i></p>'
|
|
|
|
);
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNoParagraphWithInlineRootNode()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Parent', 'span');
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'Par
|
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
Par2'
|
2007-06-24 21:35:34 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testInlineAndBlockTagInDivNoParagraph()
|
|
|
|
{
|
2007-09-27 00:39:05 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><code>bar</code> mmm <pre>asdf</pre></div>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testInlineAndBlockTagInDivNeedingParagraph()
|
|
|
|
{
|
2007-09-27 00:39:05 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><code>bar</code> mmm
|
|
|
|
|
|
|
|
<pre>asdf</pre></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p><code>bar</code> mmm</p>
|
|
|
|
|
|
|
|
<pre>asdf</pre></div>'
|
2007-09-27 00:39:05 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph()
|
|
|
|
{
|
2007-09-27 00:39:05 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>asdf <code>bar</code> mmm
|
|
|
|
|
|
|
|
<pre>asdf</pre></div>',
|
2008-08-10 04:32:29 +00:00
|
|
|
'<div><p>asdf <code>bar</code> mmm</p>
|
|
|
|
|
|
|
|
<pre>asdf</pre></div>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testUpcomingTokenHasNewline()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>Test<b>foo</b>bar<b>bing</b>bang
|
|
|
|
|
|
|
|
boo</div>',
|
|
|
|
'<div><p>Test<b>foo</b>bar<b>bing</b>bang</p>
|
|
|
|
|
|
|
|
<p>boo</p></div>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testEmptyTokenAtEndOfDiv()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><p>foo</p>
|
|
|
|
</div>',
|
|
|
|
'<div><p>foo</p>
|
|
|
|
</div>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testEmptyDoubleLineTokenAtEndOfDiv()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div><p>foo</p>
|
|
|
|
|
|
|
|
</div>',
|
|
|
|
'<div><p>foo</p>
|
|
|
|
|
|
|
|
</div>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTextState11Root()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult('<div></div> ');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTextState11Element()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
"<div><div></div>
|
|
|
|
|
|
|
|
</div>");
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testTextStateLikeElementState111NoWhitespace()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult('<div><p>P</p>Boo</div>', '<div><p>P</p>Boo</div>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testElementState111NoWhitespace()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult('<div><p>P</p><b>Boo</b></div>', '<div><p>P</p><b>Boo</b></div>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testElementState133()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
"<div><b>B</b><pre>Ba</pre>
|
|
|
|
|
|
|
|
Bar</div>",
|
|
|
|
"<div><b>B</b><pre>Ba</pre>
|
|
|
|
|
|
|
|
<p>Bar</p></div>"
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testElementState22()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<ul><li>foo</li></ul>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testElementState311()
|
|
|
|
{
|
2008-08-10 04:32:29 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p>Foo</p><b>Bar</b>',
|
|
|
|
'<p>Foo</p>
|
|
|
|
|
|
|
|
<p><b>Bar</b></p>'
|
2007-09-27 00:39:05 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testAutoClose()
|
|
|
|
{
|
2010-02-15 07:55:33 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<p></p>
|
|
|
|
<hr />'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testErrorNeeded()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Allowed', 'b');
|
2007-06-28 13:06:15 +00:00
|
|
|
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
|
2007-08-08 05:38:52 +00:00
|
|
|
$this->assertResult('<b>foobar</b>');
|
2007-06-28 13:06:15 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testParentElement()
|
|
|
|
{
|
2013-05-22 00:19:59 +00:00
|
|
|
$this->config->set('HTML.Allowed', 'p,ul,li');
|
|
|
|
$this->assertResult('Foo<ul><li>Bar</li></ul>', "<p>Foo</p>\n\n<ul><li>Bar</li></ul>");
|
|
|
|
}
|
|
|
|
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|