Help with compiling Pandoc with citeproc from Processing pane

ta
talazem
Posts: 93
Joined: Wed Nov 29, 2006 2:43 am
Platform: Mac
Location: UK

Sat Jan 09, 2021 1:49 pm Post

Hello. I have successfully set up the post-Processing pane to execute Pandoc. I am trying to use Pandoc with the defaults:

Code: Select all

Path: /usr/local/bin/pandoc
Arguments: -drefs -dlatex -dpdf-xelatex <$inputfile> -o <$outputname>.pdf
Environment: /library/tex/texbin:/Users/NAME/.local/share/pandoc/


However, Scrivener fails to compile and hangs (spinning beachball) when the `refs` default file (called up by `-drefs`) includes:

Code: Select all

verbosity: INFO


If I set `verbosity:` to `ERROR` or `WARNING`, Scrivener doesn't hang and compiles fine.

However, if I run Pandoc form the Terminal command line with `verbosity` set to `INFO`, it produces the output correctly.

Any idea why this is happening?

User avatar
nontroppo
Posts: 1281
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Sat Jan 09, 2021 3:18 pm Post

With INFO, pandoc returns content to stdout, and perhaps this causes problems for Scrivener... I also use INFO verbosity with pandoc but always redirect output to a log file from the Scrivener settings so I can catch all the useful outputs like missing references etc:

Code: Select all

Arguments: "<$inputfile>" 2>&1 >>output.log


This appends all output to a log file...

ta
talazem
Posts: 93
Joined: Wed Nov 29, 2006 2:43 am
Platform: Mac
Location: UK

Sat Jan 09, 2021 10:06 pm Post

Many thanks, Ian, for the help. You pointed me in the right direction, but to get it to work, I had to make a couple of modifications:

1. putting <$inputfile> in quotes threw up an error.
2. 2>&1 >> output.log produced an empty log.

What worked for me was:

Arguments: -drefs -dlatex -dpdf-xelatex <$inputfile> -o <$outputname>.pdf 2> output.log

From what I understand, this should only be outputting stderr and not stdout. But it looks like both to me, when I one the output.log. Not sure why this is, but at least I can check font problems and other errors.

User avatar
nontroppo
Posts: 1281
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Sun Jan 10, 2021 3:19 am Post

Hm, quoting works for me and it seems strange this would be different for you, but whatever works!

Regarding redirection, actually the order matters[1] at least for bash so try this:

Code: Select all

"<$inputfile>" >>output.log 2>&1


> redirects stdout to the file and 2>&1 redirects stderr to stdout, and why order matters I have no idea but shell scripting is a perpetual battle against flexible syntax and logic :lol:


----
[1] the previous order works for me and perhaps this is a zsh vs. bash difference? I use zsh everywhere...

ta
talazem
Posts: 93
Joined: Wed Nov 29, 2006 2:43 am
Platform: Mac
Location: UK

Sun Jan 10, 2021 10:23 am Post

Excellent, this now works perfectly. I'm not sure if it is a bash vs zsh difference, as I am using the latter in my terminal. But what matters it is now working. Thank you.

User avatar
nontroppo
Posts: 1281
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Mon Jan 11, 2021 12:39 am Post

Great, &> should also work and is a little bit less verbose:

Replace

Code: Select all

-v -l "<$inputfile>" &> scrivomatic.log


Append

Code: Select all

-v -l "<$inputfile>" &>> scrivomatic.log


http://zsh.sourceforge.net/Doc/Release/Redirection.html

- - - - - -
EDIT: actually Scrivener's post-processor appears to use bash and while &> is supported and works, &>> does not:

Code: Select all

/bin/bash: -c: line 0: syntax error near unexpected token `>'
/bin/bash: -c: line 0: `/var/folders/pb/3zl9r9sn6bqb29yvxcc77v640000gn/T/my-script -v -l 'myfile.md' &>>scrivomatic.log'