Files
resume/src/main.py
T
ewpt3ch 043af0b6fa
ci/woodpecker/push/woodpecker Pipeline was successful
added ats friendly remume
2026-04-21 20:47:00 -06:00

74 lines
2.1 KiB
Python

from pathlib import Path
from jinja2 import Environment, FileSystemLoader
from htmltopdf import htmltopdf
from mdtohtml import mdtohtml
j2_env = Environment(loader=FileSystemLoader("templates"))
srcdir = Path("markdown")
destdir = Path("publish")
name = "Eric W Phillips - Resume"
def main():
print("Hello from resume!")
# html
# process all files ending with '.md' in srcdir to html
# get the files
if not srcdir.is_dir():
return f'Error: "{srcdir}" is not a directory or does not exist'
filelist = list(srcdir.glob("*.md"))
# mk destdir if not exist
if not destdir.is_dir():
destdir.mkdir()
# process filelist
for infile in filelist:
print(f"processing '{infile}' to html")
# Read markdown once
with infile.open(mode="r", encoding="utf-8") as f:
mdsrc = f.read()
rawhtml = mdtohtml(mdsrc)
base_name = infile.stem
# pretty pdf
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)
# 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_bar = download_template.render(
web_pdf=f"{base_name}-web.pdf", ats_pdf=f"{base_name}-ats.pdf"
)
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)
print(f"Created: {web_pdf_path.name}")
print(f"Created: {ats_pdf_path.name}")
print(f"Created: {html_path.name}")
if __name__ == "__main__":
main()