mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-10 01:06:20 +02:00
[1.7.0] Finish implementing legacy elements, begin implementing legacy attributes
- Migrated most unit tests over to XHTML 1.0 Strict to preserve transformation behavior - Created %Core.ColorKeywords to be shared between CSS_Color and HTML_Color - Added AttrDef_HTML_Color as AttrType Color - HTMLPurifier_Config::create(HTMLPurifier_Config $config) now clones the object - Attribute minimization for HTML implemented in Generator - Move div@align fix from proprietary to regular set - Color keywords now map to full six digit hexadecimal codes - Harness will now tack on per-use-case configuration git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1084 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDef/HTML/Bool.php';
|
||||
|
||||
/**
|
||||
* XHTML 1.1 Legacy module defines elements that were previously
|
||||
* deprecated.
|
||||
@ -24,9 +26,28 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
var $name = 'Legacy';
|
||||
|
||||
function HTMLPurifier_HTMLModule_Legacy() {
|
||||
$this->addElement('u', true, 'Inline', 'Inline', 'Common');
|
||||
|
||||
$this->addElement('basefont', true, 'Inline', 'Empty', false, array(
|
||||
'color' => 'Color',
|
||||
'face' => 'Text', // extremely broad, we should
|
||||
'size' => 'Text', // tighten it
|
||||
'id' => 'ID'
|
||||
));
|
||||
$this->addElement('center', true, 'Block', 'Flow', 'Common');
|
||||
$this->addElement('dir', true, 'Block', 'Required: li', 'Common', array(
|
||||
'compact' => new HTMLPurifier_AttrDef_HTML_Bool('compact')
|
||||
));
|
||||
$this->addElement('font', true, 'Inline', 'Inline', array('Core', 'I18N'), array(
|
||||
'color' => 'Color',
|
||||
'face' => 'Text', // extremely broad, we should
|
||||
'size' => 'Text', // tighten it
|
||||
));
|
||||
$this->addElement('menu', true, 'Block', 'Required: li', 'Common', array(
|
||||
'compact' => new HTMLPurifier_AttrDef_HTML_Bool('compact')
|
||||
));
|
||||
$this->addElement('s', true, 'Inline', 'Inline', 'Common');
|
||||
$this->addElement('strike', true, 'Inline', 'Inline', 'Common');
|
||||
$this->addElement('u', true, 'Inline', 'Inline', 'Common');
|
||||
|
||||
// setup modifications to old elements
|
||||
|
||||
@ -36,6 +57,8 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
$ol =& $this->addBlankElement('ol');
|
||||
$ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
|
||||
|
||||
$align = new HTMLPurifier_AttrDef_Enum(array('left', 'right', 'center', 'justify'));
|
||||
|
||||
$address =& $this->addBlankElement('address');
|
||||
$address->content_model = 'Inline | #PCDATA | p';
|
||||
$address->content_model_type = 'optional';
|
||||
@ -46,6 +69,24 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
$blockquote->content_model_type = 'optional';
|
||||
$blockquote->child = false;
|
||||
|
||||
$br =& $this->addBlankElement('br');
|
||||
$br->attr['clear'] = new HTMLPurifier_AttrDef_Enum(array('left', 'all', 'right', 'none'));
|
||||
|
||||
$caption =& $this->addBlankElement('caption');
|
||||
$caption->attr['align'] = new HTMLPurifier_AttrDef_Enum(array('top', 'bottom', 'left', 'right'));
|
||||
|
||||
$div =& $this->addBlankElement('div');
|
||||
$div->attr['align'] = $align;
|
||||
|
||||
// dl.compact omitted
|
||||
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$h =& $this->addBlankElement("h$i");
|
||||
$h->attr['align'] = $align;
|
||||
}
|
||||
|
||||
// to be continued...
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,16 +10,7 @@ class HTMLPurifier_HTMLModule_Tidy_Proprietary extends
|
||||
var $defaultLevel = 'light';
|
||||
|
||||
function makeFixes() {
|
||||
$r = array();
|
||||
|
||||
// {{{ // duplicated from XHTMLAndHTML4: not sure how to factor out
|
||||
$align_lookup = array();
|
||||
$align_values = array('left', 'right', 'center', 'justify');
|
||||
foreach ($align_values as $v) $align_lookup[$v] = "text-align:$v;";
|
||||
// }}}
|
||||
$r['div@align'] = new HTMLPurifier_AttrTransform_EnumToCSS('align', $align_lookup);
|
||||
|
||||
return $r;
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
|
||||
$r['h5@align'] =
|
||||
$r['h6@align'] =
|
||||
$r['p@align'] =
|
||||
$r['div@align'] =
|
||||
new HTMLPurifier_AttrTransform_EnumToCSS('align', $align_lookup);
|
||||
|
||||
// @bgcolor for table, tr, td, th ---------------------------------
|
||||
@ -179,7 +180,7 @@ class HTMLPurifier_HTMLModule_Tidy_Transitional extends
|
||||
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
|
||||
{
|
||||
var $name = 'Tidy_Transitional';
|
||||
var $defaultLevel = 'light'; // switch this to heavy once we implement legacy fully
|
||||
var $defaultLevel = 'heavy';
|
||||
}
|
||||
|
||||
class HTMLPurifier_HTMLModule_Tidy_Strict extends
|
||||
|
Reference in New Issue
Block a user