When I call to pandoc with "-V args" like for example: '-V title="Wartość"' in Python script, I get output without title..:(
Example: Manually typed command to pandoca(in terminal):
/usr/bin/pandoc /home/user/program/content.md -V title="Wartość"
-V authors="Jerry" --output=/home/user/program/outputs/book_22.pdf
It works :) output file: pandoc output when use manually pandoc in the terminal
but when I run the same command in python(call to pandoc):
subprocess.call(['/usr/bin/pandoc', '/home/user/program/content.md', '-V title="Wartość", -V authors="Jerry" ', '--output=/home/user/program/outputs/book_33.pdf'])
output file: pandoc output when I call to him from python script
how to fix it?
Your assumption that you are running the "same command" in Python is incorrect. You have combined arguments into a single string when they should be separate.
subprocess.call(['/usr/bin/pandoc', '/home/user/program/content.md',
'-V', 'title="Wartość"', '-V', 'authors="Jerry"',
'--output=/home/user/program/outputs/book_33.pdf'])
An easy way to convert a command line to a list suitable for subprocess.call()
is shlex.split()
.