"""Build the HTML version of the paper with make4ht (tex4ht) + dvisvgm. Usage: python3 build_html.py Requires make4ht, dvisvgm and a TeX installation with TikZ. """ import glob, os, shutil, subprocess, sys here = os.path.dirname(os.path.abspath(__file__)) src, out = os.path.abspath(sys.argv[1]), sys.argv[2] os.makedirs(out, exist_ok=True) os.chdir(out) # tex4ht has its own diagrams.4ht, so rename our picture file shutil.copy(os.path.join(src, "diagrams.tex"), "stdiagrams.tex") tex = open(os.path.join(src, "pivotal_St.tex")).read() extra = (r"\input{stdiagrams.tex}" "\n" r"\renewcommand{\Di}[1]{\HCode{}\D{#1}\HCode{}}" "\n" r"\renewenvironment{quote}{\par\HCode{
}}{\par\HCode{
}}") assert tex.count(r"\input{diagrams.tex}") == 1 open("pivotal_St.tex", "w").write(tex.replace(r"\input{diagrams.tex}", extra)) with open("build.log", "w") as log: subprocess.run(["make4ht", "-u", "-f", "html5", "pivotal_St.tex", "svg"], stdout=log, stderr=log, check=True) subprocess.run([sys.executable, os.path.join(here, "html_post.py"), "."], check=True) for pat in ["*.4ct", "*.4tc", "*.aux", "*.dvi", "*.idv", "*.lg", "*.log", "*.tmp", "*.xref", "stdiagrams.tex", "pivotal_St.tex"]: for f in glob.glob(pat): os.remove(f)