htdebeer / pandocomatic

Automate the use of pandoc
https://heerdebeer.org/Software/markdown/pandocomatic/
GNU General Public License v3.0
158 stars 14 forks source link

Possible problem with Escaping with pdf-engine-opt #79

Closed herculosh closed 4 years ago

herculosh commented 4 years ago

Hello @htdebeer

I was able to create the PDF with Pandoc without any problems. Now I have tried to rebuild the call in Pandocomatic. When I set a directory via pdf-engine-opt, it seems that there are problems with escaping. When creating with Pandocomatic, I always get the error: Error producing PDF.

My code in Yaml file

      pdf-engine-opt: 
        - "--shell-escape"
        - "--outdir=temp"
        - "--aux-directory=temp"
        - "-lualatex"

Debug Output in Console:

    --pdf-engine-opt=--shell-escape \
    --pdf-engine-opt=--outdir\=temp \
    --pdf-engine-opt=--aux-directory\=temp \
    --pdf-engine-opt=-lualatex \

Is it possible that the = sign should not be escaped here?

Thanks a lot for your Help. Herculosh

htdebeer commented 4 years ago

Yes, escaping the "=" character seems odd. I will look into this over the weekend.

htdebeer commented 4 years ago

I have trouble reproducing the issue. Can you create a file test_pdf_engine_opts.md with the following contents and run pandocomatic -i test_pdf_engine_opts.md:

---
title: Test PDF engine options with = sign
pandocomatic_:
  pandoc:
    from: markdown
    to: pdf
    pdf-engine: pdflatex
    pdf-engine-opt:
    - "-shell-escape"
    - "-output-directory=temp"
...

This is a test of PDF engine options with a "=" sign and other escaping
issues.

This works on my machine as expected. If it does not work for you, please tell what version of pandocomatic and pandoc you are using. If it does work, but your original issue still persists, try to create a minimal example where the issue does occur so I might be able to reproduce it.

herculosh commented 4 years ago

I could not reproduce the problem with your example, because I use a YAML file for the generation. Now I have rebuilt the example in paru, I don't know if this example would be better stored in the repository. Well I will send you a link with the files for traceability anyway.

I have tried different options and possibilities:

$ pandocomatic -i test_pdf_engine_opts_yaml.md -c pandocomatic_variable_removed.yaml --debug                                                               
pandoc  --from=markdown \
    --to=latex \
    --variable=classoption\=t \
    --pdf-engine=pdflatex \
    --pdf-engine-opt=--shell-escape \
    --pdf-engine-opt=--output-directory\=temp \
    --output=/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.pdf
Pandocomatic needed 1.6 seconds to convert '/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.md' to 'test_pdf_engine_opts_yaml.pdf'.

$ cat pandocomatic_variable_removed.yaml                                                                                                                                
settings:
  follow-links: false
  recursive: true
  match-files: 'all'
  skip: ['*.jpg','*.pygtex','*.png','**/temp/**', '*.pdf', '*.pptx']
templates:
  test-pdf-opt:
    glob: ['test_pdf_engine_opts_yaml.md']
    pandoc:
      from: markdown
      to: pdf
      variable:
        - "classoption=t" # Make all Text on top.
      pdf-engine: lualatex
      pdf-engine-opt:
        - "--shell-escape"
        - "--output-directory=temp"
#        - "--aux-directory=temp"%

$ pandocomatic -i test_pdf_engine_opts_yaml.md -c pandocomatic_variable_removed.yaml --debug                                                                           
pandoc  --from=markdown \
    --to=latex \
    --variable=classoption\=t \
    --pdf-engine=lualatex \
    --pdf-engine-opt=--shell-escape \
    --pdf-engine-opt=--output-directory\=temp \
    --output=/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.pdf
Pandocomatic needed 4.9 seconds to convert '/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.md' to 'test_pdf_engine_opts_yaml.pdf'.

$ cat pandocomatic_variable_removed.yaml                                                                                                                                 -- INSERT --
settings:
  follow-links: false
  recursive: true
  match-files: 'all'
  skip: ['*.jpg','*.pygtex','*.png','**/temp/**', '*.pdf', '*.pptx']
templates:
  test-pdf-opt:
    glob: ['test_pdf_engine_opts_yaml.md']
    pandoc:
      from: markdown
      to: pdf
      variable:
        - "classoption=t" # Make all Text on top.
      pdf-engine: latexmk
      pdf-engine-opt:
        - "--shell-escape"
        - "--outdir=temp"
        - "--aux-directory=temp"
        - "-lualatex"%

$ pandocomatic -i test_pdf_engine_opts_yaml.md -c pandocomatic_variable_removed.yaml --debug                                                                           
pandoc  --from=markdown \
    --to=latex \
    --variable=classoption\=t \
    --pdf-engine=latexmk \
    --pdf-engine-opt=--shell-escape \
    --pdf-engine-opt=--outdir\=temp \
    --pdf-engine-opt=--aux-directory\=temp \
    --pdf-engine-opt=-lualatex \
    --output=/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.pdf
Latexmk: Run number 1 of rule 'lualatex'
Latexmk: Run number 2 of rule 'lualatex'
Error producing PDF.

Error running pandoc => error while running:

pandoc  --from=markdown \
    --to=latex \
    --variable=classoption\=t \
    --pdf-engine=latexmk \
    --pdf-engine-opt=--shell-escape \
    --pdf-engine-opt=--outdir\=temp \
    --pdf-engine-opt=--aux-directory\=temp \
    --pdf-engine-opt=-lualatex \
    --output=/Users/my/Documents/gitrepos/paru/test/pandoc_input/test_pdf_engine_opts_yaml.pdf

Pandoc responded with:

Latexmk: Run number 1 of rule 'lualatex'
Latexmk: Run number 2 of rule 'lualatex'
Error producing PDF.

It turned out that the problem was latexmk that I had been using. I switched to latexmk because of minted, pandoc doesn't allow output directories, but this is a totally different problem. I am not sure I can compile my documents with lualatex directly. This test is still pending. You can close the case from my side.

Thanks for your help.

herculosh commented 4 years ago

You will find my File at: https://github.com/herculosh/paru/commit/a4884735b9b3c6feb2e075dfc74e03cd7786ee18

htdebeer commented 4 years ago

I am not sure I can compile my documents with lualatex directly.

Using the pandoc option --pdf-engine=lualatex is not working?