mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Implement "carryover" functionality, requested by Kinderlehrer <bitweaver@7doves.com>
This commit is a limited implementation of the "active formatting elements" algorithm implemented in HTML5, which preserves certain formatting elements such as <a> and <b> when exiting or entering nodes. Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -26,7 +26,7 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
|
||||
function testUnclosedTagTerminatedByParentNodeEnd() {
|
||||
$this->assertResult(
|
||||
'<b><i>Bold and italic?</b>',
|
||||
'<b><i>Bold and italic?</i></b>'
|
||||
'<b><i>Bold and italic?</i></b><i></i>'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
|
||||
|
||||
function testAutoCloseMultiple() {
|
||||
$this->assertResult(
|
||||
'<span><span><div></div>',
|
||||
'<span><span></span></span><div></div>'
|
||||
'<b><span><div></div>asdf',
|
||||
'<b><span></span></b><div><b></b></div><b>asdf</b>'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -102,6 +102,20 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
|
||||
);
|
||||
}
|
||||
|
||||
function testLongCarryOver() {
|
||||
$this->assertResult(
|
||||
'<b>asdf<div>asdf<i>df</i></div>asdf</b>',
|
||||
'<b>asdf</b><div><b>asdf<i>df</i></b></div><b>asdf</b>'
|
||||
);
|
||||
}
|
||||
|
||||
function testInterleaved() {
|
||||
$this->assertResult(
|
||||
'<u>foo<i>bar</u>baz</i>',
|
||||
'<u>foo<i>bar</i></u><i>baz</i>'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
Reference in New Issue
Block a user