removed temporary html

This commit is contained in:
Navan Chauhan 2020-11-10 19:00:02 +05:30
parent d71af2078a
commit 57ccecf3fa
1 changed files with 31 additions and 33 deletions

64
main.py
View File

@ -5,8 +5,8 @@ from mdutils import MdUtils
markdown = True markdown = True
pdf = True pdf = False
html = False html = True
html_stylesheet = "styles/simple.css" html_stylesheet = "styles/simple.css"
title_animation = "fade-down" title_animation = "fade-down"
heading_animation = "fade-right" heading_animation = "fade-right"
@ -136,52 +136,50 @@ if html:
ifname = str(title.strip()) + ".md" ifname = str(title.strip()) + ".md"
ofname = "temp.html" ofname = str(title.strip()) + ".html"
fname = str(title.strip()) + ".html"
convert = pypandoc.convert_file(ifname,'html5',outputfile=ofname,extra_args=['-s']) convert = pypandoc.convert_file(ifname,'html5',outputfile=ofname,extra_args=['-s'])
assert(convert) == '' 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') font = soup.new_tag('link',href=html_stylesheet,rel='stylesheet')
soup.head.append(aos_css) soup.head.append(font)
font = soup.new_tag('link',href=html_stylesheet,rel='stylesheet') title = soup.new_tag('title')
soup.head.append(font) title.string = "DailyDose"
soup.head.append(title)
title = soup.new_tag('title') aos_js = soup.new_tag('script',src="https://unpkg.com/aos@2.3.1/dist/aos.js")
title.string = "DailyDose" soup.head.append(aos_js)
soup.head.append(title)
aos_js = soup.new_tag('script',src="https://unpkg.com/aos@2.3.1/dist/aos.js") aos_script = soup.new_tag('script')
soup.head.append(aos_js) aos_script.string = "AOS.init();"
aos_script = soup.new_tag('script') soup.body.append(aos_script)
aos_script.string = "AOS.init();"
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: soup.find("h1",{"id":"daily-dose"})['data-aos'] = title_animation
ToFindID = str("from-"+str(feed.strip().replace(":","").replace(" ","-").lower())) soup.find("h1",{"id":"contents"})['data-aos'] = heading_animation
ToEdit = soup.find("h1", {"id": ToFindID})
ToEdit['data-aos'] = 'fade-right'
soup.find("h1",{"id":"daily-dose"})['data-aos'] = title_animation paragraphs = soup.find_all("p")
soup.find("h1",{"id":"contents"})['data-aos'] = heading_animation for paras in paragraphs:
paras['data-aos'] = list_animation
paragraphs = soup.find_all("p") lis = soup.find_all("li")
for paras in paragraphs: for li in lis:
paras['data-aos'] = list_animation if li.a == None:
li['data-aos'] = list_animation
lis = soup.find_all("li") with open(ofname, "w") as outf:
for li in lis:
if li.a == None:
li['data-aos'] = list_animation
with open(fname, "w") as outf:
outf.write(str(soup)) outf.write(str(soup))