diff --git a/fanficfare/adapters/adapter_archiveofourownorg.py b/fanficfare/adapters/adapter_archiveofourownorg.py index 54f5445c..96f23d68 100644 --- a/fanficfare/adapters/adapter_archiveofourownorg.py +++ b/fanficfare/adapters/adapter_archiveofourownorg.py @@ -396,6 +396,18 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter): if i == 0: self.setSeries(series_name, series_index) self.story.setMetadata('seriesUrl',series_url) + + + if 'style' in self.getConfigList('keep_html_attrs',[]): + divmain = metasoup.find('div',{'id':'main'}) + if divmain: + # we sort of assume ddmain exists because otherwise, there would be no fic + workskin = divmain.style + if workskin: + workskin = str(workskin.contents[0]) # 'contents' returns a list with (here) a single element + # some transformation to adjust which classes are affected + workskin = workskin.replace('#workskin', '.userstuff') + self.story.extra_css = "/*start of AO3 workskin*/\n" + workskin + "\n/* end of AO3 workskin*/\n" def hookForUpdates(self,chaptercount): if self.newestChapterNum and self.oldchapters and len(self.oldchapters) > self.newestChapterNum: diff --git a/fanficfare/story.py b/fanficfare/story.py index 106c1624..a0353a92 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -700,6 +700,7 @@ class Story(Requestable): self.chapter_text_replacements = [] self.in_ex_cludes = {} self.chapters = [] # chapters will be dict containing(url,title,html,etc) + self.extra_css = "" self.chapter_first = None self.chapter_last = None diff --git a/fanficfare/writers/base_writer.py b/fanficfare/writers/base_writer.py index e7b013d0..9f3fa88d 100644 --- a/fanficfare/writers/base_writer.py +++ b/fanficfare/writers/base_writer.py @@ -172,10 +172,19 @@ class BaseStoryWriter(Requestable): # minor cheat, tucking css into metadata. if self.getConfig("output_css"): - self.story.setMetadata("output_css", - self.getConfig("output_css"), - condremoveentities=False) + temp_css = self.getConfig("output_css") else: + temp_css = '' + if self.story.extra_css != '': + if temp_css != '': + temp_css += '\n' + temp_css += self.story.extra_css + + if temp_css: + self.story.setMetadata("output_css", + temp_css, + condremoveentities=False) + else: self.story.setMetadata("output_css",'') if not outstream: