Use regex in the lxml parser to support case-insensitive attribute parsing

This commit is contained in:
Jannis Leidel
2012-05-19 15:32:26 +02:00
parent 7ea20ca54d
commit 9aa8f5a426
2 changed files with 3 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
from compressor.base import Compressor, SOURCE_HUNK, SOURCE_FILE
from compressor.conf import settings
from compressor.exceptions import UncompressableFileError
class CssCompressor(Compressor):

View File

@@ -33,7 +33,9 @@ class LxmlParser(ParserBase):
return tree
def css_elems(self):
return self.tree.xpath('link[@rel="stylesheet"]|style')
return self.tree.xpath(
'//meta[re:test(., "^link\[\@rel=\"stylesheet\"\]|style$", "i")]',
namespaces={"re": "http://exslt.org/regular-expressions"})
def js_elems(self):
return self.tree.findall('script')