diff options
Diffstat (limited to 'library/HTMLPurifier/HTMLModule/Tidy')
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/Name.php | 15 | ||||
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php | 14 | ||||
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/Strict.php | 28 | ||||
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/Transitional.php | 7 | ||||
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/XHTML.php | 15 | ||||
-rw-r--r-- | library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php | 146 |
6 files changed, 150 insertions, 75 deletions
diff --git a/library/HTMLPurifier/HTMLModule/Tidy/Name.php b/library/HTMLPurifier/HTMLModule/Tidy/Name.php index 61ff85ce2..a995161b2 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/Name.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/Name.php @@ -5,18 +5,27 @@ */ class HTMLPurifier_HTMLModule_Tidy_Name extends HTMLPurifier_HTMLModule_Tidy { + /** + * @type string + */ public $name = 'Tidy_Name'; + + /** + * @type string + */ public $defaultLevel = 'heavy'; - public function makeFixes() { + /** + * @return array + */ + public function makeFixes() + { $r = array(); - // @name for img, a ----------------------------------------------- // Technically, it's allowed even on strict, so we allow authors to use // it. However, it's deprecated in future versions of XHTML. $r['img@name'] = $r['a@name'] = new HTMLPurifier_AttrTransform_Name(); - return $r; } } diff --git a/library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php b/library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php index 14c15c4a0..332643821 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/Proprietary.php @@ -3,10 +3,21 @@ class HTMLPurifier_HTMLModule_Tidy_Proprietary extends HTMLPurifier_HTMLModule_Tidy { + /** + * @type string + */ public $name = 'Tidy_Proprietary'; + + /** + * @type string + */ public $defaultLevel = 'light'; - public function makeFixes() { + /** + * @return array + */ + public function makeFixes() + { $r = array(); $r['table@background'] = new HTMLPurifier_AttrTransform_Background(); $r['td@background'] = new HTMLPurifier_AttrTransform_Background(); @@ -18,7 +29,6 @@ class HTMLPurifier_HTMLModule_Tidy_Proprietary extends HTMLPurifier_HTMLModule_T $r['table@height'] = new HTMLPurifier_AttrTransform_Length('height'); return $r; } - } // vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/HTMLModule/Tidy/Strict.php b/library/HTMLPurifier/HTMLModule/Tidy/Strict.php index c73dc3c4d..803c44fab 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/Strict.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/Strict.php @@ -2,18 +2,40 @@ class HTMLPurifier_HTMLModule_Tidy_Strict extends HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 { + /** + * @type string + */ public $name = 'Tidy_Strict'; + + /** + * @type string + */ public $defaultLevel = 'light'; - public function makeFixes() { + /** + * @return array + */ + public function makeFixes() + { $r = parent::makeFixes(); $r['blockquote#content_model_type'] = 'strictblockquote'; return $r; } + /** + * @type bool + */ public $defines_child_def = true; - public function getChildDef($def) { - if ($def->content_model_type != 'strictblockquote') return parent::getChildDef($def); + + /** + * @param HTMLPurifier_ElementDef $def + * @return HTMLPurifier_ChildDef_StrictBlockquote + */ + public function getChildDef($def) + { + if ($def->content_model_type != 'strictblockquote') { + return parent::getChildDef($def); + } return new HTMLPurifier_ChildDef_StrictBlockquote($def->content_model); } } diff --git a/library/HTMLPurifier/HTMLModule/Tidy/Transitional.php b/library/HTMLPurifier/HTMLModule/Tidy/Transitional.php index 9960b1dd1..c095ad974 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/Transitional.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/Transitional.php @@ -2,7 +2,14 @@ class HTMLPurifier_HTMLModule_Tidy_Transitional extends HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 { + /** + * @type string + */ public $name = 'Tidy_Transitional'; + + /** + * @type string + */ public $defaultLevel = 'heavy'; } diff --git a/library/HTMLPurifier/HTMLModule/Tidy/XHTML.php b/library/HTMLPurifier/HTMLModule/Tidy/XHTML.php index db5a378e5..3ecddc434 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/XHTML.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/XHTML.php @@ -2,16 +2,25 @@ class HTMLPurifier_HTMLModule_Tidy_XHTML extends HTMLPurifier_HTMLModule_Tidy { - + /** + * @type string + */ public $name = 'Tidy_XHTML'; + + /** + * @type string + */ public $defaultLevel = 'medium'; - public function makeFixes() { + /** + * @return array + */ + public function makeFixes() + { $r = array(); $r['@lang'] = new HTMLPurifier_AttrTransform_Lang(); return $r; } - } // vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php b/library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php index 02e943813..c4f16a4dc 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php +++ b/library/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php @@ -3,69 +3,86 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule_Tidy { - public function makeFixes() { - + /** + * @return array + */ + public function makeFixes() + { $r = array(); // == deprecated tag transforms =================================== - $r['font'] = new HTMLPurifier_TagTransform_Font(); - $r['menu'] = new HTMLPurifier_TagTransform_Simple('ul'); - $r['dir'] = new HTMLPurifier_TagTransform_Simple('ul'); - $r['center'] = new HTMLPurifier_TagTransform_Simple('div', 'text-align:center;'); - $r['u'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:underline;'); - $r['s'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;'); + $r['font'] = new HTMLPurifier_TagTransform_Font(); + $r['menu'] = new HTMLPurifier_TagTransform_Simple('ul'); + $r['dir'] = new HTMLPurifier_TagTransform_Simple('ul'); + $r['center'] = new HTMLPurifier_TagTransform_Simple('div', 'text-align:center;'); + $r['u'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:underline;'); + $r['s'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;'); $r['strike'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;'); // == deprecated attribute transforms ============================= $r['caption@align'] = - new HTMLPurifier_AttrTransform_EnumToCSS('align', array( - // we're following IE's behavior, not Firefox's, due - // to the fact that no one supports caption-side:right, - // W3C included (with CSS 2.1). This is a slightly - // unreasonable attribute! - 'left' => 'text-align:left;', - 'right' => 'text-align:right;', - 'top' => 'caption-side:top;', - 'bottom' => 'caption-side:bottom;' // not supported by IE - )); + new HTMLPurifier_AttrTransform_EnumToCSS( + 'align', + array( + // we're following IE's behavior, not Firefox's, due + // to the fact that no one supports caption-side:right, + // W3C included (with CSS 2.1). This is a slightly + // unreasonable attribute! + 'left' => 'text-align:left;', + 'right' => 'text-align:right;', + 'top' => 'caption-side:top;', + 'bottom' => 'caption-side:bottom;' // not supported by IE + ) + ); // @align for img ------------------------------------------------- $r['img@align'] = - new HTMLPurifier_AttrTransform_EnumToCSS('align', array( - 'left' => 'float:left;', - 'right' => 'float:right;', - 'top' => 'vertical-align:top;', - 'middle' => 'vertical-align:middle;', - 'bottom' => 'vertical-align:baseline;', - )); + new HTMLPurifier_AttrTransform_EnumToCSS( + 'align', + array( + 'left' => 'float:left;', + 'right' => 'float:right;', + 'top' => 'vertical-align:top;', + 'middle' => 'vertical-align:middle;', + 'bottom' => 'vertical-align:baseline;', + ) + ); // @align for table ----------------------------------------------- $r['table@align'] = - new HTMLPurifier_AttrTransform_EnumToCSS('align', array( - 'left' => 'float:left;', - 'center' => 'margin-left:auto;margin-right:auto;', - 'right' => 'float:right;' - )); + new HTMLPurifier_AttrTransform_EnumToCSS( + 'align', + array( + 'left' => 'float:left;', + 'center' => 'margin-left:auto;margin-right:auto;', + 'right' => 'float:right;' + ) + ); // @align for hr ----------------------------------------------- $r['hr@align'] = - new HTMLPurifier_AttrTransform_EnumToCSS('align', array( - // we use both text-align and margin because these work - // for different browsers (IE and Firefox, respectively) - // and the melange makes for a pretty cross-compatible - // solution - 'left' => 'margin-left:0;margin-right:auto;text-align:left;', - 'center' => 'margin-left:auto;margin-right:auto;text-align:center;', - 'right' => 'margin-left:auto;margin-right:0;text-align:right;' - )); + new HTMLPurifier_AttrTransform_EnumToCSS( + 'align', + array( + // we use both text-align and margin because these work + // for different browsers (IE and Firefox, respectively) + // and the melange makes for a pretty cross-compatible + // solution + 'left' => 'margin-left:0;margin-right:auto;text-align:left;', + 'center' => 'margin-left:auto;margin-right:auto;text-align:center;', + 'right' => 'margin-left:auto;margin-right:0;text-align:right;' + ) + ); // @align for h1, h2, h3, h4, h5, h6, p, div ---------------------- // {{{ - $align_lookup = array(); - $align_values = array('left', 'right', 'center', 'justify'); - foreach ($align_values as $v) $align_lookup[$v] = "text-align:$v;"; + $align_lookup = array(); + $align_values = array('left', 'right', 'center', 'justify'); + foreach ($align_values as $v) { + $align_lookup[$v] = "text-align:$v;"; + } // }}} $r['h1@align'] = $r['h2@align'] = @@ -73,7 +90,7 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule $r['h4@align'] = $r['h5@align'] = $r['h6@align'] = - $r['p@align'] = + $r['p@align'] = $r['div@align'] = new HTMLPurifier_AttrTransform_EnumToCSS('align', $align_lookup); @@ -88,12 +105,15 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule // @clear for br -------------------------------------------------- $r['br@clear'] = - new HTMLPurifier_AttrTransform_EnumToCSS('clear', array( - 'left' => 'clear:left;', - 'right' => 'clear:right;', - 'all' => 'clear:both;', - 'none' => 'clear:none;', - )); + new HTMLPurifier_AttrTransform_EnumToCSS( + 'clear', + array( + 'left' => 'clear:left;', + 'right' => 'clear:right;', + 'all' => 'clear:both;', + 'none' => 'clear:none;', + ) + ); // @height for td, th --------------------------------------------- $r['td@height'] = @@ -125,19 +145,19 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule // @type for li, ol, ul ------------------------------------------- // {{{ - $ul_types = array( - 'disc' => 'list-style-type:disc;', - 'square' => 'list-style-type:square;', - 'circle' => 'list-style-type:circle;' - ); - $ol_types = array( - '1' => 'list-style-type:decimal;', - 'i' => 'list-style-type:lower-roman;', - 'I' => 'list-style-type:upper-roman;', - 'a' => 'list-style-type:lower-alpha;', - 'A' => 'list-style-type:upper-alpha;' - ); - $li_types = $ul_types + $ol_types; + $ul_types = array( + 'disc' => 'list-style-type:disc;', + 'square' => 'list-style-type:square;', + 'circle' => 'list-style-type:circle;' + ); + $ol_types = array( + '1' => 'list-style-type:decimal;', + 'i' => 'list-style-type:lower-roman;', + 'I' => 'list-style-type:upper-roman;', + 'a' => 'list-style-type:lower-alpha;', + 'A' => 'list-style-type:upper-alpha;' + ); + $li_types = $ul_types + $ol_types; // }}} $r['ul@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $ul_types); @@ -153,9 +173,7 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule $r['hr@width'] = new HTMLPurifier_AttrTransform_Length('width'); return $r; - } - } // vim: et sw=4 sts=4 |