jump to class: ignore case of rel attribute on link elements

This commit is contained in:
Kovid Goyal 2024-09-09 21:54:33 +05:30
parent 83ad6604bf
commit 13c8ee358c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -5,11 +5,11 @@ from contextlib import suppress
from typing import List, NamedTuple, Optional, Tuple
from css_parser.css import CSSRule
from css_selectors import Select, SelectorError
from calibre.ebooks.oeb.parse_utils import barename
from calibre.ebooks.oeb.polish.container import get_container
from calibre.ebooks.oeb.polish.parsing import parse
from css_selectors import Select, SelectorError
class NoMatchingTagFound(KeyError):
@ -116,7 +116,7 @@ def find_first_matching_rule(
)
if res is not None:
return res._replace(style_tag_address=(int(tag.get(lnum_attr)), ['style']))
elif tn == 'link' and tag.get('href') and tag.get('rel') == 'stylesheet':
elif tn == 'link' and tag.get('href') and tag.get('rel', '').lower() == 'stylesheet':
sname = container.href_to_name(tag.get('href'), html_file_name)
try:
sheet = container.parsed(sname)