mirror of
https://github.com/leoncvlt/loconotion.git
synced 2024-08-30 18:12:12 +00:00
Added support for emoji spreadsheets
This commit is contained in:
parent
73c21cc607
commit
29bf4969e2
@ -352,7 +352,7 @@ class Parser:
|
|||||||
log.debug(f"Adding meta tag {str(tag)}")
|
log.debug(f"Adding meta tag {str(tag)}")
|
||||||
soup.head.append(tag)
|
soup.head.append(tag)
|
||||||
|
|
||||||
# process images
|
# process images & emojis
|
||||||
cache_images = True
|
cache_images = True
|
||||||
for img in soup.findAll("img"):
|
for img in soup.findAll("img"):
|
||||||
if img.has_attr("src"):
|
if img.has_attr("src"):
|
||||||
@ -372,6 +372,21 @@ class Parser:
|
|||||||
if img["src"].startswith("/"):
|
if img["src"].startswith("/"):
|
||||||
img["src"] = "https://www.notion.so" + img["src"]
|
img["src"] = "https://www.notion.so" + img["src"]
|
||||||
|
|
||||||
|
# on emoji images, cache their sprite sheet and re-set their background url
|
||||||
|
if img.has_attr("class") and "notion-emoji" in img["class"]:
|
||||||
|
style = cssutils.parseStyle(img["style"])
|
||||||
|
spritesheet = style["background"]
|
||||||
|
spritesheet_url = spritesheet[
|
||||||
|
spritesheet.find("(") + 1 : spritesheet.find(")")
|
||||||
|
]
|
||||||
|
cached_spritesheet_url = self.cache_file(
|
||||||
|
"https://www.notion.so" + spritesheet_url
|
||||||
|
)
|
||||||
|
style["background"] = spritesheet.replace(
|
||||||
|
spritesheet_url, str(cached_spritesheet_url)
|
||||||
|
)
|
||||||
|
img["style"] = style.cssText
|
||||||
|
|
||||||
# process stylesheets
|
# process stylesheets
|
||||||
for link in soup.findAll("link", rel="stylesheet"):
|
for link in soup.findAll("link", rel="stylesheet"):
|
||||||
if link.has_attr("href") and link["href"].startswith("/"):
|
if link.has_attr("href") and link["href"].startswith("/"):
|
||||||
|
Loading…
Reference in New Issue
Block a user