HTMLPurifier_Filter_ExtractStyleBlocks
extends HTMLPurifier_Filter
in package
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.
Tags
Table of Contents
Properties
- $name : mixed
- Name of the filter for identification purposes.
- $_class_attrdef : mixed
- $_enum_attrdef : mixed
- $_id_attrdef : mixed
- $_styleMatches : mixed
- $_tidy : mixed
Methods
- __construct() : mixed
- cleanCSS() : string
- Takes CSS (the stuff found in <style>) and cleans it.
- postFilter() : string
- Post-processor function, handles HTML after HTML Purifier
- preFilter() : string
- Removes inline <style> tags from HTML, saves them for later use
- styleCallback() : mixed
- Save the contents of CSS blocks to style matches
Properties
$name
Name of the filter for identification purposes.
public
mixed
$name
= 'ExtractStyleBlocks'
Tags
$_class_attrdef
private
mixed
$_class_attrdef
Tags
$_enum_attrdef
private
mixed
$_enum_attrdef
Tags
$_id_attrdef
private
mixed
$_id_attrdef
Tags
$_styleMatches
private
mixed
$_styleMatches
= array()
Tags
$_tidy
private
mixed
$_tidy
Tags
Methods
__construct()
public
__construct() : mixed
cleanCSS()
Takes CSS (the stuff found in <style>) and cleans it.
public
cleanCSS(string $css, HTMLPurifier_Config $config, HTMLPurifier_Context $context) : string
Parameters
- $css : string
-
CSS styling to clean
- $config : HTMLPurifier_Config
- $context : HTMLPurifier_Context
Tags
Return values
string —Cleaned CSS
postFilter()
Post-processor function, handles HTML after HTML Purifier
public
postFilter(string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context) : string
Parameters
- $html : string
- $config : HTMLPurifier_Config
- $context : HTMLPurifier_Context
Return values
stringpreFilter()
Removes inline <style> tags from HTML, saves them for later use
public
preFilter(string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context) : string
Parameters
- $html : string
- $config : HTMLPurifier_Config
- $context : HTMLPurifier_Context
Tags
Return values
stringstyleCallback()
Save the contents of CSS blocks to style matches
protected
styleCallback(array<string|int, mixed> $matches) : mixed
Parameters
- $matches : array<string|int, mixed>
-
preg_replace style $matches array