HTMLPurifier 4.4.0
HTMLPurifier_Filter_ExtractStyleBlocks Class Reference

This filter extracts <style> blocks from input HTML, cleans them up using CSSTidy, and then places them in $purifier->context->get('StyleBlocks') so they can be used elsewhere in the document. More...

Inheritance diagram for HTMLPurifier_Filter_ExtractStyleBlocks:
HTMLPurifier_Filter

List of all members.

Public Member Functions

 __construct ()
 preFilter ($html, $config, $context)
 Removes inline <style> tags from HTML, saves them for later use.
 cleanCSS ($css, $config, $context)
 Takes CSS (the stuff found in <style>) and cleans it.

Public Attributes

 $name = 'ExtractStyleBlocks'
 Name of the filter for identification purposes.

Protected Member Functions

 styleCallback ($matches)
 Save the contents of CSS blocks to style matches.

Private Attributes

 $_styleMatches = array()
 $_tidy
 $_id_attrdef
 $_class_attrdef
 $_enum_attrdef

Detailed Description

This filter extracts <style> blocks from input HTML, cleans them up using CSSTidy, and then places them in $purifier->context->get('StyleBlocks') so they can be used elsewhere in the document.

Note:
See tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php for sample usage.
This filter can also be used on stylesheets not included in the document--something purists would probably prefer. Just directly call HTMLPurifier_Filter_ExtractStyleBlocks->cleanCSS()

Definition at line 23 of file ExtractStyleBlocks.php.


Constructor & Destructor Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::__construct ( )

Definition at line 34 of file ExtractStyleBlocks.php.


Member Function Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::cleanCSS ( css,
config,
context 
)

Takes CSS (the stuff found in <style>) and cleans it.

Warning:
Requires CSSTidy <http://csstidy.sourceforge.net/>
Parameters:
$cssCSS styling to clean
$configInstance of HTMLPurifier_Config
$contextInstance of HTMLPurifier_Context
Returns:
Cleaned CSS

Definition at line 76 of file ExtractStyleBlocks.php.

References $config, $def, and $name.

Referenced by preFilter().

HTMLPurifier_Filter_ExtractStyleBlocks::preFilter ( html,
config,
context 
)

Removes inline <style> tags from HTML, saves them for later use.

Todo:
Extend to indicate non-text/css style blocks

Reimplemented from HTMLPurifier_Filter.

Definition at line 53 of file ExtractStyleBlocks.php.

References $config, $html, and cleanCSS().

HTMLPurifier_Filter_ExtractStyleBlocks::styleCallback ( matches) [protected]

Save the contents of CSS blocks to style matches.

Parameters:
$matchespreg_replace style $matches array

Definition at line 45 of file ExtractStyleBlocks.php.


Member Data Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::$_class_attrdef [private]

Definition at line 31 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$_enum_attrdef [private]

Definition at line 32 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$_id_attrdef [private]

Definition at line 30 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$_styleMatches = array() [private]

Definition at line 27 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$_tidy [private]

Definition at line 28 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$name = 'ExtractStyleBlocks'

Name of the filter for identification purposes.

Reimplemented from HTMLPurifier_Filter.

Definition at line 26 of file ExtractStyleBlocks.php.

Referenced by cleanCSS().


The documentation for this class was generated from the following file: