1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-09 16:56:20 +02:00

[1.7.0] Convert Image, Legacy and List to use new format.

- Make attribute array parameter optional
- Optimize contents parsing for keywords

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1041 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-05-09 22:01:07 +00:00
parent b81fb0af90
commit 7f39e1e2c3
5 changed files with 52 additions and 44 deletions

View File

@ -9,7 +9,6 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
{
var $name = 'List';
var $elements = array('dl', 'dt', 'dd', 'ol', 'ul', 'li');
// According to the abstract schema, the List content set is a fully formed
// one or more expr, but it invariably occurs in an optional declaration
@ -19,26 +18,31 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
// Furthermore, the actual XML Schema may disagree. Regardless,
// we don't have support for such nested expressions without using
// the incredibly inefficient and draconic Custom ChildDef.
var $content_sets = array('List' => 'dl | ol | ul', 'Flow' => 'List');
var $content_sets = array('Flow' => 'List');
function HTMLPurifier_HTMLModule_List() {
foreach ($this->elements as $element) {
$this->info[$element] = new HTMLPurifier_ElementDef();
$this->info[$element]->attr = array(0 => array('Common'));
if ($element == 'li' || $element == 'dd') {
$this->info[$element]->content_model = '#PCDATA | Flow';
$this->info[$element]->content_model_type = 'optional';
} elseif ($element == 'ol' || $element == 'ul') {
$this->info[$element]->content_model = 'li';
$this->info[$element]->content_model_type = 'required';
}
}
$this->info['dt']->content_model = '#PCDATA | Inline';
$this->info['dt']->content_model_type = 'optional';
$this->info['dl']->content_model = 'dt | dd';
$this->info['dl']->content_model_type = 'required';
// this could be a LOT more robust
$this->addElement(
'ol', true, 'List', 'Required: li', 'Common'
);
$this->addElement(
'ul', true, 'List', 'Required: li', 'Common'
);
$this->addElement(
'dl', true, 'List', 'Required: dt | dd', 'Common'
);
$this->addElement(
'li', true, false, 'Flow', 'Common'
);
$this->info['li']->auto_close = array('li' => true);
$this->addElement(
'dd', true, false, 'Flow', 'Common'
);
$this->addElement(
'dt', true, false, 'Inline', 'Common'
);
}
}