0

I'm using jinja in python to render a .tex file, and then I want to use xelatex to render it to a pdf. Although I've managed to get this to work with an intermediate file, I'd rather not have an intermediate file.

I want to try doing this with a pipe. I'm writing to the pipe like this, after running the jinja2 render:

with open("./utils/xelatex_pipe", "w") as pipe:
    pipe.write(output)

This seems to be fine, because if I run cat ./utils/xelatex_pipe, I get the expected data (the .tex file).

I am now trying to set up a bash script that listens to that pipe, and runs xelatex on anything that comes through it. I've tried something like this:

pipe=./xelatex_pipe

xelatex -output-directory=/tmp/ $pipe

This doesn't work. It seems to treat every line individually, which obviously causes xelatex to go to mad... I think I need to aggregate all of the lines into a file, but I'm not sure how to do something like "while there are still lines in the pipe, concatenate them to some variable, and then run xelatex on the variable once there are no more lines"

Alex
  • 2,270
  • 3
  • 33
  • 65
  • You write into _./utils/xelatex_pipe_ and read from _./xelatex_handler_? That is not the same pipe! – UtLox Mar 15 '19 at 18:31
  • That was dumb... – Alex Mar 15 '19 at 18:35
  • I've fixed that, but it still doesn't work. It seems to be treating each line individually, rather than the document as a whole – Alex Mar 15 '19 at 18:41
  • You can use shared memory instead of pipes. E.g with jinja write to _/dev/shm/mytexfile.tex_ and read it with xelatex. – UtLox Mar 15 '19 at 18:53

0 Answers0