format fixes with ruff
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from weasyprint import HTML
|
from weasyprint import HTML
|
||||||
|
|
||||||
|
|
||||||
def htmltopdf(html, file):
|
def htmltopdf(html, file):
|
||||||
HTML(string=html).write_pdf(file)
|
HTML(string=html).write_pdf(file)
|
||||||
|
|||||||
+11
-8
@@ -1,14 +1,16 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from mdtohtml import mdtohtml
|
|
||||||
from htmltopdf import htmltopdf
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
j2_env = Environment(loader=FileSystemLoader('templates'))
|
from htmltopdf import htmltopdf
|
||||||
|
from mdtohtml import mdtohtml
|
||||||
|
|
||||||
|
j2_env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
|
||||||
srcdir = Path("markdown")
|
srcdir = Path("markdown")
|
||||||
destdir = Path("publish")
|
destdir = Path("publish")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Hello from resume!")
|
print("Hello from resume!")
|
||||||
|
|
||||||
@@ -18,7 +20,7 @@ def main():
|
|||||||
# get the files
|
# get the files
|
||||||
if not srcdir.is_dir():
|
if not srcdir.is_dir():
|
||||||
return f'Error: "{srcdir}" is not a directory or does not exist'
|
return f'Error: "{srcdir}" is not a directory or does not exist'
|
||||||
filelist = list(srcdir.glob('*.md'))
|
filelist = list(srcdir.glob("*.md"))
|
||||||
|
|
||||||
# mk destdir if not exist
|
# mk destdir if not exist
|
||||||
if not destdir.is_dir():
|
if not destdir.is_dir():
|
||||||
@@ -33,24 +35,25 @@ def main():
|
|||||||
|
|
||||||
# md -> html
|
# md -> html
|
||||||
print(f"processing '{infile}' to html")
|
print(f"processing '{infile}' to html")
|
||||||
with infile.open(mode='r', encoding='utf-8') as f:
|
with infile.open(mode="r", encoding="utf-8") as f:
|
||||||
mdsrc = f.read()
|
mdsrc = f.read()
|
||||||
rawhtml = mdtohtml(mdsrc)
|
rawhtml = mdtohtml(mdsrc)
|
||||||
|
|
||||||
# html -> resume.template
|
# html -> resume.template
|
||||||
print("processing rawhtml through resume.template")
|
print("processing rawhtml through resume.template")
|
||||||
template = j2_env.get_template('resume.template')
|
template = j2_env.get_template("resume.template")
|
||||||
pdfhtml = template.render(content=rawhtml, download="")
|
pdfhtml = template.render(content=rawhtml, download="")
|
||||||
|
|
||||||
print(f"processing html to '{outfilepdf}'")
|
print(f"processing html to '{outfilepdf}'")
|
||||||
htmltopdf(pdfhtml, outfilepdf)
|
htmltopdf(pdfhtml, outfilepdf)
|
||||||
|
|
||||||
print(f"processing pdfhtml to '{outfile}'")
|
print(f"processing pdfhtml to '{outfile}'")
|
||||||
download_template = j2_env.get_template('download.template')
|
download_template = j2_env.get_template("download.template")
|
||||||
download_bar = download_template.render(pdffile=outfilepdf.name)
|
download_bar = download_template.render(pdffile=outfilepdf.name)
|
||||||
pubhtml = template.render(content=rawhtml, download=download_bar)
|
pubhtml = template.render(content=rawhtml, download=download_bar)
|
||||||
with outfile.open(mode='w', encoding='utf-8') as f:
|
with outfile.open(mode="w", encoding="utf-8") as f:
|
||||||
f.write(pubhtml)
|
f.write(pubhtml)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
from markdown_it import MarkdownIt
|
from markdown_it import MarkdownIt
|
||||||
|
|
||||||
md = MarkdownIt("commonmark").enable('table')
|
md = MarkdownIt("commonmark").enable("table")
|
||||||
|
|
||||||
|
|
||||||
def mdtohtml(mdsrc):
|
def mdtohtml(mdsrc):
|
||||||
rawhtml = md.render(mdsrc)
|
rawhtml = md.render(mdsrc)
|
||||||
|
|||||||
Reference in New Issue
Block a user