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


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 17 of file ExtractStyleBlocks.php.


Constructor & Destructor Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::__construct (  ) 

Definition at line 24 of file ExtractStyleBlocks.php.


Member Function Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::styleCallback ( matches  )  [protected]

Save the contents of CSS blocks to style matches.

Parameters:
$matches preg_replace style $matches array

Definition at line 32 of file ExtractStyleBlocks.php.

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 40 of file ExtractStyleBlocks.php.

References cleanCSS(), and styleCallback().

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:
$css CSS styling to clean
$config Instance of HTMLPurifier_Config
$context Instance of HTMLPurifier_Context
Returns:
Cleaned CSS

Definition at line 63 of file ExtractStyleBlocks.php.

References $name.

Referenced by preFilter().


Member Data Documentation

HTMLPurifier_Filter_ExtractStyleBlocks::$name = 'ExtractStyleBlocks'

Name of the filter for identification purposes.

Reimplemented from HTMLPurifier_Filter.

Definition at line 20 of file ExtractStyleBlocks.php.

Referenced by cleanCSS().

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

Definition at line 21 of file ExtractStyleBlocks.php.

HTMLPurifier_Filter_ExtractStyleBlocks::$_tidy [private]

Definition at line 22 of file ExtractStyleBlocks.php.


The documentation for this class was generated from the following file:
Generated on Thu Jun 19 18:47:30 2008 for HTMLPurifier by  doxygen 1.5.3