From f8025b146f79422535b39cfd622d9c729b9630f2 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Wed, 4 Feb 2026 18:35:35 -0700 Subject: [PATCH] format fixes with ruff --- src/htmltopdf.py | 1 + src/main.py | 19 +++++++++++-------- src/mdtohtml.py | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/htmltopdf.py b/src/htmltopdf.py index f6dbf4d..e222b57 100644 --- a/src/htmltopdf.py +++ b/src/htmltopdf.py @@ -1,4 +1,5 @@ from weasyprint import HTML + def htmltopdf(html, file): HTML(string=html).write_pdf(file) diff --git a/src/main.py b/src/main.py index 8a23eb0..29a8dab 100644 --- a/src/main.py +++ b/src/main.py @@ -1,14 +1,16 @@ from pathlib import Path -from mdtohtml import mdtohtml -from htmltopdf import htmltopdf 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") destdir = Path("publish") + def main(): print("Hello from resume!") @@ -18,7 +20,7 @@ def main(): # 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')) + filelist = list(srcdir.glob("*.md")) # mk destdir if not exist if not destdir.is_dir(): @@ -33,24 +35,25 @@ def main(): # md -> 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() rawhtml = mdtohtml(mdsrc) # html -> 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="") print(f"processing html to '{outfilepdf}'") htmltopdf(pdfhtml, outfilepdf) 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) 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) + if __name__ == "__main__": main() diff --git a/src/mdtohtml.py b/src/mdtohtml.py index e1118cf..942399e 100644 --- a/src/mdtohtml.py +++ b/src/mdtohtml.py @@ -1,6 +1,7 @@ from markdown_it import MarkdownIt -md = MarkdownIt("commonmark").enable('table') +md = MarkdownIt("commonmark").enable("table") + def mdtohtml(mdsrc): rawhtml = md.render(mdsrc)