From 9b73160837b5de09d77c9607183f83ae79424a57 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 10 Jan 2024 09:55:53 +0800 Subject: [PATCH] move link elements in 'head' into 'body' Anki seems to replace the original head element with it's own head element,which makes the CSS styles in the original document unusable. That's why we need to move the link elements in the 'head' element into the 'body' element --- ir/importer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ir/importer.py b/ir/importer.py index 199b2fb..5c5ca30 100644 --- a/ir/importer.py +++ b/ir/importer.py @@ -80,6 +80,12 @@ def _cleanWebpage(self, html, url, local=False): for link in webpage.find_all('link'): self._processLinkTag(url, link, local) + headlinks = webpage.head.find_all('link') + headlinks.reverse() + for link in headlinks: + if 'stylesheet' in link['rel']: + webpage.body.insert(0, link) + return webpage def _createNote(self, title, text, source, priority=None):