Chromium Code Reviews| Index: chrome/browser/web_dev_style/css_checker.py |
| diff --git a/chrome/browser/web_dev_style/css_checker.py b/chrome/browser/web_dev_style/css_checker.py |
| index 7d03a60feb8bd7b846cc94ed52edaa50beb03e2a..67f0ffca236fc1dcd4c750d8bede2f5b56d62fe3 100644 |
| --- a/chrome/browser/web_dev_style/css_checker.py |
| +++ b/chrome/browser/web_dev_style/css_checker.py |
| @@ -36,6 +36,11 @@ class CSSChecker(object): |
| s = _remove_mixins(s) |
| return s |
| + def _extract_inline_style(s): |
| + style_reg = re.compile(r"""<style>([^<]*)<\/style>""") |
| + styles = style_reg.findall(s) |
| + return '\n'.join(styles) |
|
Dan Beam
2016/01/27 02:50:45
nit: to improve your code golf swing
return '\n
tsergeant
2016/01/27 03:12:14
Done, one-upping by getting rid of the compile.
|
| + |
| def _remove_ats(s): |
| at_reg = re.compile(r""" |
| @(?!\d+x\b)\w+[^'"]*?{ # @at-keyword selector junk {, not @2x |
| @@ -375,13 +380,19 @@ class CSSChecker(object): |
| file_filter=self.file_filter) |
| files = [] |
| for f in affected_files: |
| - # Remove all /*comments*/, @at-keywords, and grit <if|include> tags; we're |
| - # not using a real parser. TODO(dbeam): Check alpha in <if> blocks. |
| - file_contents = _remove_all('\n'.join(f.NewContents())) |
| - files.append((f.LocalPath(), file_contents)) |
| - |
| - # Only look at CSS files for now. |
| - for f in filter(lambda f: f[0].endswith('.css'), files): |
| + file_contents = '\n'.join(f.NewContents()) |
| + path = f.LocalPath() |
| + # Handle CSS files and HTML files with inline styles. |
| + if path.endswith('.html'): |
| + file_contents = _extract_inline_style(file_contents) |
|
Dan Beam
2016/01/27 02:50:45
nit: \n
tsergeant
2016/01/27 03:12:14
Done.
|
| + if path.endswith('.html') or path.endswith('.css'): |
| + # Remove all /*comments*/, @at-keywords, and grit <if|include> tags; |
| + # we're not using a real parser. TODO(dbeam): Check alpha in <if> |
| + # blocks. |
| + file_contents = _remove_all(file_contents) |
| + files.append((path, file_contents)) |
| + |
| + for f in files: |
| file_errors = [] |
| for check in added_or_modified_files_checks: |
| # If the check is multiline, it receieves the whole file and gives us |