Now, I try to do this through Scrivener, with path C:\Users\me\AppData\Local\Pandoc\pandoc.exe and arguments: --reference-doc="C:\Users\me\AppData\Roaming\pandoc\handout.docx" --lua-filter=zotero.lua --citeproc --output <$outputname>.docx
Scrivener generates the .md file but not a .docx document. What can the problem be?
I suspect the problem may be related to --reference-doc. When I run --lua-filter=zotero.lua --citeproc --output <$outputname>.docx it works.
I could save the reference template as “reference.docx” into Pandoc’s folder and it would work. However, I would like to have the --reference-doc option to create custom formats for compiling into different styles.
Before digging too deep into it, I would enable Options: General: Warnings: Show internal log console, and relaunch, then try compiling again. That will give you the shell command output, and any STDERR or STDOUT Pandoc is producing.
I can say that in general, what you are doing should work, as it works fine for me. The only difference to my setup is that I have Pandoc installed to Program Files instead of local only. I don’t think that should matter, especially given how it works for you from the shell.
Debug: Executed: "C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe"
Debug: Arguments: "--reference-doc=handout.docx --output testhandout.docx C:/Users/中文/Downloads/testhandout.md"
Debug: Working Dir: "C:/Users/中文/Downloads"
Debug: StdOut: ""
Debug: StdErr: "File handout.docx not found in resource path\r\n"
Info: Post Processing Result: "Unknown Error."
Info: Post Processing Error Description: ""
Info: Post Processing Log: "Executed:C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe\nArguments:--reference-doc=handout.docx --output testhandout.docx C:/Users/中文/Downloads/testhandout.md\nWorking Dir:C:/Users/中文/Downloads\nStdOut:\n\nStdErr:File handout.docx not found in resource path\r\n\n"
Same issue when I locate "C:\Users\中文\AppData\Roaming\pandoc\handout.docx" in the Pandoc directory.
Just in case this is somehow related, my username in Windows is in Chinese characters. In the code I provided in the previous post, I changed it to “me” for privacy reasons, but here I am representing it as “中文” just in case it matters. But I don’t see why it should matter, since the access route to pandoc.exe also contains Chinese characters, and Scrivener runs it in post-processing without any apparent issue. The problem only occurs when I try to use the --reference-doc option.
So one important difference I see, on line 2, is that you are not giving a full path to your handout.docx reference doc, like you would need to (and do in the original shell example). The error Pandoc is giving is the one you would get if the reference doc cannot be found. It’s just a little confusingly worded (in my opinion), in that it phrases it as not finding it in the resource path, which to me implies your Pandoc resource folder, but really what it means is, “File not found.”
Sorry for the confusion, that was one of the versions I used to test the problem. When I indicate the exact path as in --reference-doc="C:\handout.docx" --output <$outputname>.docx, this is the error I get:
Debug: Executed: "C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe"
Debug: Arguments: "--reference-doc=\"C:\\handout.docx\" --output testhandout.docx C:/Users/中文/Downloads/testhandout.md"
Debug: Working Dir: "C:/Users/中文/Downloads"
Debug: StdOut: ""
Debug: StdErr: "File \"C:\\handout.docx\" not found in resource path\r\n"
Info: Post Processing Result: "Unknown Error."
Info: Post Processing Error Description: ""
Info: Post Processing Log: "Executed:C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe\nArguments:--reference-doc=\"C:\\handout.docx\" --output testhandout.docx C:/Users/中文/Downloads/testhandout.md\nWorking Dir:C:/Users/中文/Downloads\nStdOut:\n\nStdErr:File \"C:\\handout.docx\" not found in resource path\r\n\n"
And when I indicate the path to the pandoc folder like this --reference-doc="C:\Users\中文\AppData\Roaming\pandoc\handout.docx" --output <$outputname>.docx:
Debug: Executed: "C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe"
Debug: Arguments: "--reference-doc=\"C:\\Users\\中文\\AppData\\Roaming\\pandoc\\handout.docx\" --output testhandout.docx C:/Users/中文/Downloads/testhandout.md"
Debug: Working Dir: "C:/Users/中文/Downloads"
Debug: StdOut: ""
Debug: StdErr: "File \"C:\\Users\\中文\AppData\\Roaming\\pandoc\\handout.docx\" not found in resource path\r\n"
Info: Post Processing Result: "Unknown Error."
Info: Post Processing Error Description: ""
Info: Post Processing Log: "Executed:C:\\Users\\中文\\AppData\\Local\\Pandoc\\pandoc.exe\nArguments:--reference-doc=\"C:\\Users\\中文\\AppData\\Roaming\\pandoc\\handout.docx\" --output testhandout.docx C:/Users/中文/Downloads/testhandout.md\nWorking Dir:C:/Users/中文/Downloads\nStdOut:\n\nStdErr:File \"C:\\Users\\中文\\AppData\\Roaming\\pandoc\\handout.docx\" not found in resource path\r\n\n"
Okay, sorry for taking a while to get back with you; I was on a short break.
I have done some further testing with this on Windows 10 itself (previously I was using Wine on Linux), and ran into the same sort of problems you discovered. So I tried to investigate it a bit further, by adding the --verbose flag to the command in my compile settings, so that it would maybe explain more of why it cannot find the file… and suddenly it started working.
This must be some very odd Pandoc bug, perhaps when being run from within a very limited shell session. I can’t think of why switching the error logging level would make a difference in whether a file can be found with a given path, otherwise.
Well, there is no downside to adding the verbose flag, so that’s a suitable workaround.