This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf/md_pdf/build/__init__.py

27 lines
977 B
Python
Raw Permalink Normal View History

2017-03-29 18:26:54 +01:00
from md_pdf.build.md import read_files
from md_pdf.build.pandoc import build_document, output_html
2017-05-17 17:52:57 +01:00
from md_pdf.build.templates import render_templates
2017-04-05 15:27:14 +01:00
from md_pdf.build.css import render_css
2017-03-29 18:26:54 +01:00
from md_pdf.build.pdf import export_pdf
2017-05-17 15:02:52 +01:00
from md_pdf.build.content import parse_template
2017-03-29 18:26:54 +01:00
import os
2017-04-01 16:12:03 +01:00
import logging
2017-05-11 09:20:35 +01:00
import time
2017-04-01 16:12:03 +01:00
logger = logging.getLogger(__file__)
2017-03-29 18:26:54 +01:00
2017-06-09 23:07:30 +01:00
def build(config: dict):
2017-04-04 22:04:25 +01:00
logger.debug("Starting Build...")
2017-05-11 09:20:35 +01:00
start_time = time.time()
2017-03-30 18:26:06 +01:00
data = read_files(os.path.abspath(config['input']))
2017-05-28 12:33:34 +01:00
doc = build_document(data, config.get('bibliography'))
2017-05-10 17:22:55 +01:00
parsed_template = parse_template(doc, config)
2017-03-30 18:26:06 +01:00
if 'html' in config['output_formats']:
2017-05-10 17:22:55 +01:00
output_html(parsed_template, os.path.abspath(config['output_dir']))
2017-03-30 18:26:06 +01:00
if 'pdf' in config['output_formats']:
render_templates(config, parsed_template)
2017-04-05 15:27:14 +01:00
render_css()
2017-05-10 17:22:55 +01:00
export_pdf(parsed_template, config)
2017-05-11 09:20:35 +01:00
logger.info('Output completed in {:.2f} seconds.'.format(time.time() - start_time))