-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrender-tikz.py
executable file
·39 lines (30 loc) · 1.1 KB
/
render-tikz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import runpy
import subprocess
import sys
sys.path.append(".")
from scripts import pdf_to_svg_png_compressed
# Get name of directory containing the TeX file.
tex_file = sys.argv[1]
# Get base path of TeX file, i.e. path without extension.
base_path = os.path.splitext(tex_file)[0]
in_dir = os.path.dirname(tex_file)
print("Running latexmk to generate PDF from TeX file")
ret_val = subprocess.run(
["latexmk", "-silent", "-pdf", f"-jobname={base_path}", tex_file],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).returncode
if os.getenv("CI") == "true":
print("Detected CI=true")
if ret_val != 0:
with open(f"{base_path}.log", "r") as f:
print(f.read())
raise SystemExit(f"latexmk failed with return code {ret_val}. See log above.")
print("Delete LaTeX auxiliary files")
for file in os.listdir(in_dir):
if file.endswith(("aux", "log", "fls", "fdb_latexmk")):
os.remove(f"{in_dir}/{file}")
pdf_to_svg_png_compressed(f"{base_path}.pdf")
print("Update readme table listing all figures in assets/")
runpy.run_path("scripts/update-readme-table.py")