summaryrefslogtreecommitdiff
path: root/texgen.py
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-06-03 15:26:02 +0800
committerKeuin <[email protected]>2023-06-03 15:26:02 +0800
commit1467767c8e26f2fe5d318114c8e0055be1c10c8e (patch)
tree3a8745f8e41c80e077d38d9fdefdbd0424b98842 /texgen.py
parented540d68256f3f05e86b7880858249a1e8a17c42 (diff)
Generate using temporary tex file
Diffstat (limited to 'texgen.py')
-rw-r--r--texgen.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/texgen.py b/texgen.py
index 851df83..f629094 100644
--- a/texgen.py
+++ b/texgen.py
@@ -40,13 +40,15 @@ class TexGenerator:
return cache_file_path
with temp_dir(os.path.join(self._temp_path, os.urandom(24).hex())) as workdir:
job_name = 'texput'
+ tex_file_path = os.path.join(self._temp_path, f'{job_name}.tex')
+ with open(tex_file_path, 'w', encoding='utf-8') as f:
+ f.write(tex_source)
with subprocess.Popen(
[
'xelatex',
'-interaction=nonstopmode',
'-halt-on-error',
- # this seems not working, as the output file name is always set to default `texput.pdf`
- f'-jobname={job_name}',
+ tex_file_path,
],
cwd=workdir,
stdin=subprocess.PIPE,
@@ -55,7 +57,7 @@ class TexGenerator:
text=True,
shell=True,
) as proc:
- stdout, stderr = proc.communicate(input=tex_source, timeout=self._task_timeout)
+ stdout, stderr = proc.communicate(input='', timeout=self._task_timeout)
print('STDOUT', stdout)
print('STDERR', stderr)
if proc.returncode != 0: