From 0ecac665de83e027256fa762ba2f368de5a6a87a Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 17 Aug 2026 11:27:12 +0200 Subject: [PATCH] copy images and generate epub --- publish.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/publish.py b/publish.py index 01e0d9d..fd2b8ba 100644 --- a/publish.py +++ b/publish.py @@ -5,6 +5,7 @@ import yaml import shutil import subprocess import unidecode +import glob htmltemplate = """ @@ -76,13 +77,22 @@ for folderinfo in index['folders']: htmlcontent = md2html(mdcontent) gmicontent = md2gmi(mdcontent) + # copy images + for f in glob.glob(os.path.join(folderinfo['folder'], "*.png")): + shutil.copy2(f, "out/html") + shutil.copy2(f, "out/gmi") + + # generate epub + subprocess.run(["pandoc", filename, "-o", "/tmp/{}".format(outfilename.replace('.md', '.epub'))], cwd=folderinfo['folder']) + shutil.move("/tmp/{}".format(outfilename.replace('.md', '.epub')), "out/html") + with open("out/html/{}".format(outfilename).replace('.md', '.html'), "w", encoding="utf-8") as htmlfile: htmlfile.write(apply_html_template(htmlcontent, "{} | {}".format(filetitle, index['title']))) with open("out/gmi/{}".format(outfilename).replace('.md', '.gmi'), "w", encoding="utf-8") as gmifile: gmifile.write(gmicontent) - htmlhome += "
  • {}
  • ".format(outfilename.replace('.md', '.html'), filetitle) + htmlhome += "
  • {} [epub]
  • ".format(outfilename.replace('.md', '.html'),filetitle,outfilename.replace('.md', '.epub')) gmihome += "\n=> {} {}".format(outfilename.replace('.md', '.gmi').replace(' ', '%20'), filetitle) elif fileextension == ".wav" or fileextension == ".3gp":