manually copied main.py from ats branch do to failed merge. do dev on a branch
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+28
-12
@@ -21,6 +21,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
|
||||||
@@ -31,27 +32,42 @@ def main():
|
|||||||
for infile in filelist:
|
for infile in filelist:
|
||||||
print(f"processing '{infile}'...")
|
print(f"processing '{infile}'...")
|
||||||
|
|
||||||
# md -> html
|
# Read markdown once
|
||||||
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
|
base_name = infile.stem
|
||||||
print("processing rawhtml through resume.template")
|
|
||||||
template = j2_env.get_template("resume.template")
|
|
||||||
pdfhtml = template.render(name=name, content=rawhtml, download="")
|
|
||||||
|
|
||||||
print(f"processing html to '{outfilepdf}'")
|
# pretty pdf
|
||||||
htmltopdf(pdfhtml, outfilepdf)
|
print("Generating web PDF...")
|
||||||
|
web_template = j2_env.get_template("resume-web.template")
|
||||||
|
web_html = web_template.render(name=name, content=rawhtml)
|
||||||
|
web_pdf_path = destdir / f"{base_name}-web.pdf"
|
||||||
|
htmltopdf(web_html, web_pdf_path)
|
||||||
|
|
||||||
print(f"processing pdfhtml to '{outfile}'")
|
# ats friendly pdf
|
||||||
|
ats_template = j2_env.get_template("resume-ats.template")
|
||||||
|
ats_html = ats_template.render(name=name, content=rawhtml)
|
||||||
|
ats_pdf_path = destdir / f"{base_name}-ats.pdf"
|
||||||
|
htmltopdf(ats_html, ats_pdf_path)
|
||||||
|
|
||||||
|
# generate web html with download bar
|
||||||
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(
|
||||||
pubhtml = template.render(content=rawhtml, download=download_bar)
|
web_pdf=f"{base_name}-web.pdf", ats_pdf=f"{base_name}-ats.pdf"
|
||||||
with outfile.open(mode="w", encoding="utf-8") as f:
|
)
|
||||||
|
|
||||||
|
pubhtml = web_template.render(name=name, content=rawhtml, download=download_bar)
|
||||||
|
|
||||||
|
html_path = destdir / f"{base_name}.html"
|
||||||
|
with html_path.open(mode="w", encoding="utf-8") as f:
|
||||||
f.write(pubhtml)
|
f.write(pubhtml)
|
||||||
|
|
||||||
|
print(f"Created: {web_pdf_path.name}")
|
||||||
|
print(f"Created: {ats_pdf_path.name}")
|
||||||
|
print(f"Created: {html_path.name}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user