mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Simplify some code
This commit is contained in:
parent
acfcc63cfc
commit
eb6317512f
@ -308,7 +308,7 @@ def upshift_markup(parts):
|
|||||||
|
|
||||||
def handle_media_queries(raw):
|
def handle_media_queries(raw):
|
||||||
# cssutils cannot handle CSS 3 media queries. We look for media queries
|
# cssutils cannot handle CSS 3 media queries. We look for media queries
|
||||||
# that use amzn-mobi or amzn-kf8 and map them to asimple @media screen
|
# that use amzn-mobi or amzn-kf8 and map them to a simple @media screen
|
||||||
# rule. See https://bugs.launchpad.net/bugs/1406708 for an example
|
# rule. See https://bugs.launchpad.net/bugs/1406708 for an example
|
||||||
import tinycss
|
import tinycss
|
||||||
parser = tinycss.make_full_parser()
|
parser = tinycss.make_full_parser()
|
||||||
@ -317,10 +317,8 @@ def handle_media_queries(raw):
|
|||||||
for mq in sheet.rules[0].media:
|
for mq in sheet.rules[0].media:
|
||||||
# Only accept KF8 media types
|
# Only accept KF8 media types
|
||||||
if (mq.media_type, mq.negated) in {('amzn-mobi', True), ('amzn-kf8', False)}:
|
if (mq.media_type, mq.negated) in {('amzn-mobi', True), ('amzn-kf8', False)}:
|
||||||
break
|
return '@media screen {'
|
||||||
else:
|
return m.group()
|
||||||
return m.group()
|
|
||||||
return '@media screen {'
|
|
||||||
|
|
||||||
return re.sub(r'@media\s[^{]*{', replace, raw)
|
return re.sub(r'@media\s[^{]*{', replace, raw)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user