0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-23 00:41:52 +00:00

Implement Style Attribute Module, cleanup some attribute collections and add some documentation.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@716 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-02-04 18:27:59 +00:00
parent 129a4ea506
commit 6478c7c2df
5 changed files with 41 additions and 4 deletions

View File

@ -12,6 +12,7 @@ class HTMLPurifier_AttrCollection
var $info = array(
'Core' => array(
0 => array('Style'),
// 'xml:space' => false,
'class' => 'NMTOKENS',
'id' => 'ID',
@ -21,10 +22,8 @@ class HTMLPurifier_AttrCollection
'xml:lang' => false, // see constructor
'lang' => false, // see constructor
),
'Events' => array(),
'Style' => array(), // specifically empty
'Common' => array(
0 => array('Core', 'Events', 'I18N', 'Style')
0 => array('Core', 'I18N')
)
);
@ -39,6 +38,12 @@ class HTMLPurifier_AttrCollection
foreach ($modules as $module) {
foreach ($module->attr_collection as $coll_i => $coll) {
foreach ($coll as $attr_i => $attr) {
if ($attr_i === 0) {
// merge in includes
$info[$coll_i][$attr_i] = array_merge(
$info[$coll_i][$attr_i], $attr);
continue;
}
$info[$coll_i][$attr_i] = $attr;
}
}

View File

@ -22,7 +22,9 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
$this->info['bdo'] = new HTMLPurifier_ElementDef();
$this->info['bdo']->attr = array(
0 => array('Core'),
'dir' => $dir
'dir' => $dir, // required
'lang' => 'Lang',
'xml:lang' => 'Lang'
);
$this->info['bdo']->content_model = '#PCDATA | Inline';
$this->info['bdo']->content_model_type = 'optional';

View File

@ -0,0 +1,21 @@
<?php
require_once 'HTMLPurifier/HTMLModule.php';
/**
* XHTML 1.1 Edit Module, defines editing-related elements. Text Extension Module.
*/
class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule
{
var $attr_collection = array(
'Style' => array('style' => false),
'Core' => array(0 => array('Style'))
);
function HTMLPurifier_HTMLModule_StyleAttribute() {
$this->attr_collection['Style']['style'] = new HTMLPurifier_AttrDef_CSS();
}
}
?>

View File

@ -4,6 +4,13 @@ require_once 'HTMLPurifier/HTMLModule.php';
/**
* XHTML 1.1 Text Module, defines basic text containers. Core Module.
* @note In the normative XML Schema specification, this module
* is further abstracted into the following modules:
* - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
* - Block Structural (div, p)
* - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
* - Inline Structural (br, span)
* We have elected not to follow suite, but this may change.
*/
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
{

View File

@ -14,6 +14,7 @@ require_once 'HTMLPurifier/HTMLModule/Edit.php';
require_once 'HTMLPurifier/HTMLModule/Bdo.php';
require_once 'HTMLPurifier/HTMLModule/Tables.php';
require_once 'HTMLPurifier/HTMLModule/Image.php';
require_once 'HTMLPurifier/HTMLModule/StyleAttribute.php';
/**
* Next-generation HTML definition that will supplant HTMLPurifier_HTMLDefinition
@ -36,6 +37,7 @@ class HTMLPurifier_XHTMLDefinition extends HTMLPurifier_HTMLDefinition
$this->modules['Bdo'] = new HTMLPurifier_HTMLModule_Bdo();
$this->modules['Tables'] = new HTMLPurifier_HTMLModule_Tables();
$this->modules['Image'] = new HTMLPurifier_HTMLModule_Image();
$this->modules['StyleAttribute']= new HTMLPurifier_HTMLModule_StyleAttribute();
$this->attr_types = new HTMLPurifier_AttrTypes();
$this->attr_collection = new HTMLPurifier_AttrCollection();