added templates and assets with pypandoc
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user