mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Edit Book: Fix a regression that caused Remove unused CSS to fail on invalid CSS selectors, instead of ignoring them
This commit is contained in:
parent
d6f8b9501b
commit
f878552be5
@ -13,14 +13,20 @@ from calibre import force_unicode
|
||||
from calibre.ebooks.oeb.base import OEB_STYLES, OEB_DOCS
|
||||
from calibre.ebooks.oeb.normalize_css import normalize_filter_css, normalizers
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_script_or_style
|
||||
from css_selectors import Select
|
||||
from css_selectors import Select, SelectorError
|
||||
|
||||
|
||||
def filter_used_rules(rules, log, select):
|
||||
for rule in rules:
|
||||
used = False
|
||||
for selector in rule.selectorList:
|
||||
if select.has_matches(selector.selectorText):
|
||||
try:
|
||||
if select.has_matches(selector.selectorText):
|
||||
used = True
|
||||
break
|
||||
except SelectorError:
|
||||
# Cannot parse/execute this selector, be safe and assume it
|
||||
# matches something
|
||||
used = True
|
||||
break
|
||||
if not used:
|
||||
|
Loading…
x
Reference in New Issue
Block a user