42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from bs4 import BeautifulSoup
|
|
import pypandoc
|
|
import sys, os, shutil
|
|
|
|
def main():
|
|
# create main html dom from template
|
|
template_f = open("template.html", "r")
|
|
template_html = template_f.read()
|
|
template_dom = BeautifulSoup(template_html, 'html.parser')
|
|
|
|
|
|
pdoc_args = ['--mathjax',
|
|
'--smart']
|
|
|
|
pdoc_filters = []
|
|
|
|
output = pypandoc.convert_file("log.OSP",
|
|
to='html5',
|
|
format='markdown+header_attributes+link_attributes+bracketed_spans',
|
|
extra_args=pdoc_args,
|
|
filters=pdoc_filters)
|
|
# outputfile=out_f)
|
|
|
|
# print("output :\n"+output)
|
|
|
|
output_dom = BeautifulSoup(output, 'html.parser')
|
|
|
|
log = template_dom.find('div', {'class':'log'})
|
|
|
|
log.append(output_dom)
|
|
|
|
# create main html file from filled template html dom
|
|
book_html_f = os.path.join('final.html')
|
|
with open(book_html_f, 'w') as fp:
|
|
fp.write(template_dom.prettify(formatter=None))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|