*/ class Emogrifier { /** * @var string */ const ENCODING = 'UTF-8'; /** * @var int */ const CACHE_KEY_CSS = 0; /** * @var int */ const CACHE_KEY_SELECTOR = 1; /** * @var int */ const CACHE_KEY_XPATH = 2; /** * @var int */ const CACHE_KEY_CSS_DECLARATION_BLOCK = 3; /** * for calculating nth-of-type and nth-child selectors * * @var int */ const INDEX = 0; /** * for calculating nth-of-type and nth-child selectors * * @var int */ const MULTIPLIER = 1; /** * @var string */ const ID_ATTRIBUTE_MATCHER = '/(\\w+)?\\#([\\w\\-]+)/'; /** * @var string */ const CLASS_ATTRIBUTE_MATCHER = '/(\\w+|[\\*\\]])?((\\.[\\w\\-]+)+)/'; /** * @var string */ private $html = ''; /** * @var string */ private $css = ''; /** * @var string[] */ private $unprocessableHtmlTags = array('wbr'); /** * @var array[] */ private $caches = array( self::CACHE_KEY_CSS => array(), self::CACHE_KEY_SELECTOR => array(), self::CACHE_KEY_XPATH => array(), self::CACHE_KEY_CSS_DECLARATION_BLOCK => array(), ); /** * the visited nodes with the XPath paths as array keys * * @var \DOMNode[] */ private $visitedNodes = array(); /** * the styles to apply to the nodes with the XPath paths as array keys for the outer array * and the attribute names/values as key/value pairs for the inner array * * @var array[] */ private $styleAttributesForNodes = array(); /** * Determines whether the "style" attributes of tags in the the HTML passed to this class should be preserved. * If set to false, the value of the style attributes will be discarded. * * @var bool */ private $isInlineStyleAttributesParsingEnabled = true; /** * Determines whether the