diff options
author | Keuin <[email protected]> | 2023-06-03 15:26:02 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-06-03 15:26:02 +0800 |
commit | 1467767c8e26f2fe5d318114c8e0055be1c10c8e (patch) | |
tree | 3a8745f8e41c80e077d38d9fdefdbd0424b98842 /texgen.py | |
parent | ed540d68256f3f05e86b7880858249a1e8a17c42 (diff) |
Generate using temporary tex file
Diffstat (limited to 'texgen.py')
-rw-r--r-- | texgen.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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: |