Allow scss styles
This commit is contained in:
parent
3800f43bd1
commit
490263f7cd
6 changed files with 31 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -89,5 +89,6 @@ ENV/
|
|||
|
||||
out/
|
||||
md_pdf/assets/templates/cover.html
|
||||
md_pdf/assets/static/style.css
|
||||
md_pdf/assets/csl/
|
||||
md_pdf/assets/styles-master/
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
body.cover {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body.cover h1 {
|
||||
font-size: 48px;
|
||||
padding-top: 400px;
|
||||
}
|
10
md_pdf/assets/static/style.scss
Normal file
10
md_pdf/assets/static/style.scss
Normal file
|
@ -0,0 +1,10 @@
|
|||
body.cover {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
|
||||
& h1 {
|
||||
font-size: 48px;
|
||||
padding-top: 400px;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
from md_pdf.build.md import read_files
|
||||
from md_pdf.build.pandoc import build_document, output_html
|
||||
from md_pdf.build.cover import render_cover
|
||||
from md_pdf.build.css import render_css
|
||||
from md_pdf.build.pdf import export_pdf
|
||||
import os
|
||||
import logging
|
||||
|
@ -16,4 +17,5 @@ def build(config):
|
|||
output_html(doc, os.path.abspath(config['output_dir']))
|
||||
if 'pdf' in config['output_formats']:
|
||||
render_cover(config)
|
||||
render_css()
|
||||
export_pdf(doc, config)
|
||||
|
|
17
md_pdf/build/css.py
Normal file
17
md_pdf/build/css.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from scss import Compiler
|
||||
from md_pdf.consts import STATIC_DIR
|
||||
from md_pdf.build.pdf import STYLE_FILE
|
||||
import os
|
||||
|
||||
|
||||
STYLE_SRC_FILE = os.path.join(STATIC_DIR, 'style.scss')
|
||||
|
||||
|
||||
def render_css():
|
||||
compiler = Compiler()
|
||||
with open(STYLE_SRC_FILE) as f:
|
||||
style = f.read()
|
||||
with open(STYLE_FILE, 'w') as f:
|
||||
data = compiler.compile_string(style)
|
||||
f.write(data)
|
||||
return data
|
1
setup.py
1
setup.py
|
@ -10,6 +10,7 @@ setup(
|
|||
"pdfkit==0.6.1",
|
||||
"progressbar2==3.16.0",
|
||||
"pypandoc==1.3.3",
|
||||
"pyscss==1.3.5",
|
||||
"PyYAML==3.12"
|
||||
],
|
||||
entry_points="""
|
||||
|
|
Reference in a new issue