From 57ccecf3faaf09ef1c82b0f3a073ebf7838fe2ed Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Tue, 10 Nov 2020 19:00:02 +0530 Subject: [PATCH] removed temporary html --- main.py | 64 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/main.py b/main.py index d994577..ccb0e41 100644 --- a/main.py +++ b/main.py @@ -5,8 +5,8 @@ from mdutils import MdUtils markdown = True -pdf = True -html = False +pdf = False +html = True html_stylesheet = "styles/simple.css" title_animation = "fade-down" heading_animation = "fade-right" @@ -136,52 +136,50 @@ if html: ifname = str(title.strip()) + ".md" - ofname = "temp.html" - fname = str(title.strip()) + ".html" + ofname = str(title.strip()) + ".html" convert = pypandoc.convert_file(ifname,'html5',outputfile=ofname,extra_args=['-s']) assert(convert) == '' - fp = open(ofname) + with open(ofname) as fp: + soup = BeautifulSoup(fp,'html5lib') - soup = BeautifulSoup(fp,'html5lib') + aos_css = soup.new_tag('link',href='https://unpkg.com/aos@2.3.1/dist/aos.css',rel='stylesheet') + soup.head.append(aos_css) - aos_css = soup.new_tag('link',href='https://unpkg.com/aos@2.3.1/dist/aos.css',rel='stylesheet') - soup.head.append(aos_css) + font = soup.new_tag('link',href=html_stylesheet,rel='stylesheet') + soup.head.append(font) - font = soup.new_tag('link',href=html_stylesheet,rel='stylesheet') - soup.head.append(font) + title = soup.new_tag('title') + title.string = "DailyDose" + soup.head.append(title) - title = soup.new_tag('title') - title.string = "DailyDose" - soup.head.append(title) + aos_js = soup.new_tag('script',src="https://unpkg.com/aos@2.3.1/dist/aos.js") + soup.head.append(aos_js) - aos_js = soup.new_tag('script',src="https://unpkg.com/aos@2.3.1/dist/aos.js") - soup.head.append(aos_js) + aos_script = soup.new_tag('script') + aos_script.string = "AOS.init();" - aos_script = soup.new_tag('script') - aos_script.string = "AOS.init();" + soup.body.append(aos_script) - soup.body.append(aos_script) + for feed in rss_feeds: + ToFindID = str("from-"+str(feed.strip().replace(":","").replace(" ","-").lower())) + ToEdit = soup.find("h1", {"id": ToFindID}) + ToEdit['data-aos'] = 'fade-right' - for feed in rss_feeds: - ToFindID = str("from-"+str(feed.strip().replace(":","").replace(" ","-").lower())) - ToEdit = soup.find("h1", {"id": ToFindID}) - ToEdit['data-aos'] = 'fade-right' + soup.find("h1",{"id":"daily-dose"})['data-aos'] = title_animation + soup.find("h1",{"id":"contents"})['data-aos'] = heading_animation - soup.find("h1",{"id":"daily-dose"})['data-aos'] = title_animation - soup.find("h1",{"id":"contents"})['data-aos'] = heading_animation + paragraphs = soup.find_all("p") + for paras in paragraphs: + paras['data-aos'] = list_animation - paragraphs = soup.find_all("p") - for paras in paragraphs: - paras['data-aos'] = list_animation + lis = soup.find_all("li") + for li in lis: + if li.a == None: + li['data-aos'] = list_animation - lis = soup.find_all("li") - for li in lis: - if li.a == None: - li['data-aos'] = list_animation - - with open(fname, "w") as outf: + with open(ofname, "w") as outf: outf.write(str(soup))