added templates and assets with pypandoc

This commit is contained in:
Bachir Soussi Chiadmi
2017-03-26 03:03:48 +02:00
parent c81294b930
commit 55c06ee81a
155 changed files with 27211 additions and 8 deletions
+19 -8
View File
@@ -16,6 +16,7 @@ import re
BOOKS_SRC = 'book-src'
BUILD_d = "build"
CUR_PATH = os.path.dirname(os.path.abspath(__file__))
def main():
if not os.path.isdir(BUILD_d):
@@ -53,7 +54,7 @@ def parse_book(book):
sum_dom = BeautifulSoup(sum_html, 'html.parser')
# print(sum_dom)
toc = parse_summary(sum_dom.ul, {})
print(toc)
# print(toc)
generate_html(book, toc, book_build_d)
@@ -77,7 +78,7 @@ def parse_summary(ul, toc):
def generate_html(book, toc, book_build_d):
railway = []
for p in toc:
print(toc[p]['file'])
# print(toc[p]['file'])
# generate html with pandoc
# files
@@ -86,21 +87,31 @@ def generate_html(book, toc, book_build_d):
html_f = html_f.replace('README', 'index')
html_f = html_f.replace('/', '-')
in_f = os.path.join(BOOKS_SRC, book, md_f)
print(in_f)
# print(in_f)
out_f = os.path.join(book_build_d,html_f)
print(out_f)
# print(out_f)
# pandoc options
filters = []
pdoc_args = ['--mathjax',
'--smart']
# filters = []
pdoc_args = ['-s',
'--mathjax',
'--smart',
'--css=assets/fonts/amiri/amiri.css',
'--css=assets/css/dist/styles.css',
'--include-before-body=templates/top.tpl.html',
'--include-after-body=templates/bot.tpl.html',
'--include-after-body=assets/js/jquery.min.js',
'--include-after-body=assets/js/script.js',
'--include-after-body=templates/end.tpl.html']
# pandoc command line
# print(pypandoc.get_pandoc_version())
output = pypandoc.convert_file(in_f,
to='html5',
format='md',
extra_args=pdoc_args,
filters=filters,
# filters=filters,
outputfile=out_f)
# save reference in railway