... rather than rejecting them. Fix Kozea/WeasyPrint#128
GenericTranslator offers an excelent way to support custom selectors trough method hooks and allowing to return a *new* XPathExpr from this hooks. The main problem is that returning extended `XPathExpr` instances fail for combiners because `XPathExpr.join()` assume a fixed XPathExpr instance attributes (element, path and condition) to copy from `other` to `self` `XPathExpr.join()` can be extended in subclass but needs that `left` xpath instance to be of the extended class too, and right now we can only control `right` xpath type. The problem can be mitigated by recasting all xpath returned from `GenericTranslator.xpath_element()` that only works because it is the only hook that cast `XPathExpr` instances. The proposed change allow projects extending GenericTranslator to also safely extend `XPathExpr` to correctly support combiners in extended features.
Whitespace is *not* empty.
See http://www.w3.org/TR/selectors/#casesens Pseudo-classes were already case-insensitive, but the lower-casing was moved to the parser.
For element names, these are equivalent in XPath: foo *[name() = "foo"] And for attribute names: @foo attribute:*[name() = "foo"] The former is faster but some characters are not allowed in it. Since I am not sure which characters, only use it for "safe" names that match ^[a-zA-Z_][a-zA-Z0-9_.-]*$ This is overly restrictive, but should cover every name actually used in XML, HTML, SVG, etc.
…l cssselect, on Windows with Python 2.7 64-bit.