Skip to content

Commit

Permalink
feat: render can skip rerun upcon request (will safe devel time)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeesters committed Apr 19, 2024
1 parent 3f4ab2e commit 1cb676e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions render
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import logging
import os
from pathlib import Path
import re
import shlex
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -109,12 +110,11 @@ def get_pdf_name(filename):

def run_pdflatex(fname="out.tex", path="."):
outdir = os.path.realpath(os.path.join(os.getcwd(), "slides"))

subprocess.call(
["pdflatex", "-synctex=1", "-interaction=nonstopmode", fname], cwd=path
)
cmd = shlex.split(f"pdflatex -synctex=1 -interaction=nonstopmode {fname}")
retcode = subprocess.call(cmd, cwd=path)
pdfname = get_pdf_name(fname)
shutil.copy(os.path.join(path, pdfname), os.path.join(outdir, pdfname))
return retcode


def parse_config(fname):
Expand Down Expand Up @@ -201,6 +201,9 @@ if __name__ == "__main__":
default="config/config.yaml",
help="indicate the configuration YAML file - default: 'config/config.yaml'",
)
parser.add_argument(
"-n", "--no-rerun", default=False, action=argparse.BooleanOptionalAction
)
args = parser.parse_args()

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -233,8 +236,10 @@ if __name__ == "__main__":
for section_estimate, fname in enumerate(file_list):
to_adapt = os.path.join(tempdir, "slides", fname) + ".tex"
find_and_replace_sections(boundaries, section_estimate, to_adapt)

# now the typesetting needs to be triggered
run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides"))
# re-run might be required
if args.no_rerun:
print("no rerun as requested")
sys.exit()
run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides"))

0 comments on commit 1cb676e

Please # to comment.