mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-22 09:35:59 +01:00
Edit book: When renaming classes in style sheets only recognize class names preceded by a period. Fixes #1944562 [Renaming class called "body" renames rules for body element](https://bugs.launchpad.net/calibre/+bug/1944562)
This commit is contained in:
parent
ef2e2c714c
commit
d12e14b236
1 changed files with 4 additions and 1 deletions
|
|
@ -501,7 +501,10 @@ def add_stylesheet_links(container, name, text):
|
|||
|
||||
|
||||
def rename_class_in_rule_list(css_rules, old_name, new_name):
|
||||
pat = re.compile(rf'\b{re.escape(old_name)}\b')
|
||||
# this regex will not match class names inside attribute value selectors
|
||||
# and it will match id selectors that contain .old_name but its the best
|
||||
# that can be done without implementing a full parser for CSS selectors
|
||||
pat = re.compile(rf'(?<=\.){re.escape(old_name)}\b')
|
||||
changed = False
|
||||
for rule in css_rules:
|
||||
if rule.type == rule.STYLE_RULE:
|
||||
|
|
|
|||
Loading…
Reference in a new issue