private function Emogrifier::translateCSStoXpath in HTML Mail 6
Same name and namespace in other branches
- 5 emogrifier/emogrifier.php \Emogrifier::translateCSStoXpath()
1 call to Emogrifier::translateCSStoXpath()
- Emogrifier::emogrify in emogrifier/
emogrifier.php
File
- emogrifier/
emogrifier.php, line 137 - CSS to Inline Converter Class
Class
Code
private function translateCSStoXpath($css_selector) {
// returns an Xpath selector
$search = array(
'/\\s+>\\s+/',
// Matches any F element that is a child of an element E.
'/(\\w+)\\s+\\+\\s+(\\w+)/',
// Matches any F element that is a child of an element E.
'/\\s+/',
// Matches any F element that is a descendant of an E element.
'/(\\w+)?\\#([\\w\\-]+)/e',
// Matches id attributes
'/(\\w+)?\\.([\\w\\-]+)/e',
);
$replace = array(
'/',
'\\1/following-sibling::*[1]/self::\\2',
'//',
"(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'",
"(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",@class,\" \"),concat(\" \",\"\\2\",\" \"))]'",
);
return '//' . preg_replace($search, $replace, trim($css_selector));
}