diff --git a/.gitignore b/.gitignore
index 10f78c0..45c5282 100644
--- a/.gitignore
+++ b/.gitignore
@@ -86,3 +86,6 @@ ENV/
# Rope project settings
.ropeproject
+
+out/
+md_pdf/assets/cover.html
diff --git a/md_pdf/assets/cover-template.html b/md_pdf/assets/cover-template.html
new file mode 100644
index 0000000..d84f82b
--- /dev/null
+++ b/md_pdf/assets/cover-template.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+ {{ title }}
+ {{ subtitle }}
+
+
diff --git a/md_pdf/assets/footer.html b/md_pdf/assets/footer.html
new file mode 100644
index 0000000..36471a9
--- /dev/null
+++ b/md_pdf/assets/footer.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/md_pdf/assets/header.html b/md_pdf/assets/header.html
new file mode 100644
index 0000000..f2a2694
--- /dev/null
+++ b/md_pdf/assets/header.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/md_pdf/assets/style.css b/md_pdf/assets/style.css
new file mode 100644
index 0000000..9da2ea9
--- /dev/null
+++ b/md_pdf/assets/style.css
@@ -0,0 +1,9 @@
+body.cover {
+ margin: 0 auto;
+ text-align: center;
+}
+
+body.cover h1 {
+ font-size: 72px;
+ padding-top: 400px;
+}
diff --git a/md_pdf/build/cli.py b/md_pdf/build/cli.py
index 1bf8e1d..6830758 100644
--- a/md_pdf/build/cli.py
+++ b/md_pdf/build/cli.py
@@ -1,7 +1,8 @@
import click
from md_pdf.build.md import read_files
-from md_pdf.build.pandoc import build_document
+from md_pdf.build.pandoc import build_document, output_html
from md_pdf.build.cover import render_cover
+from md_pdf.build.pdf import export_pdf
@click.command('build', short_help="Build document")
@@ -11,6 +12,9 @@ from md_pdf.build.cover import render_cover
def cli(in_files, bibliography, output):
data = read_files(in_files)
doc = build_document(data, bibliography)
+ output_html(doc, output)
render_cover()
+ export_pdf(doc, output)
+ return 0
diff --git a/md_pdf/build/pandoc.py b/md_pdf/build/pandoc.py
index bfc8826..8cd878c 100644
--- a/md_pdf/build/pandoc.py
+++ b/md_pdf/build/pandoc.py
@@ -16,6 +16,11 @@ def fix_references_title(content):
return soup.prettify()
+def output_html(html, out_dir):
+ with open(os.path.join(out_dir, 'output.html'), 'w') as f:
+ f.write(html)
+
+
def build_document(files_content, bibliography):
args = [
'-s',
diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py
index fecb86f..4454b64 100644
--- a/md_pdf/build/pdf.py
+++ b/md_pdf/build/pdf.py
@@ -1,6 +1,13 @@
import pdfkit
+from md_pdf.utils import PROJECT_DIR
+from md_pdf.build.cover import OUTPUT_COVER_FILE
+import os
-pdf_options = {
+
+STYLE_FILE = os.path.join(PROJECT_DIR, 'assets', 'style.css')
+HEADER_FILE = os.path.join(PROJECT_DIR, 'assets', 'header.html')
+FOOTER_FILE = os.path.join(PROJECT_DIR, 'assets', 'footer.html')
+PDF_OPTIONS = {
"quiet": "",
"no-pdf-compression": "",
@@ -9,8 +16,8 @@ pdf_options = {
"margin-left": '0.4in',
"margin-right": '0.4in',
- "header-html": "header.html",
- "footer-html": "footer.html",
+ "header-html": HEADER_FILE,
+ "footer-html": FOOTER_FILE,
"footer-spacing": 5,
"header-spacing": 5,
@@ -21,11 +28,11 @@ pdf_options = {
}
-def export_pdf(content):
+def export_pdf(content, out_dir):
return pdfkit.from_string(
content,
- 'out.pdf',
- options=pdf_options,
- css="style.css",
- cover="cover.html"
+ os.path.join(out_dir, 'output.pdf'),
+ options=PDF_OPTIONS,
+ css=STYLE_FILE,
+ cover=OUTPUT_COVER_FILE
)