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

Pandoc data dir as default regression? #84

Closed iandol closed 4 years ago

iandol commented 4 years ago

My pandocomatic.yaml is kept in the pandoc data dir, which is /Users/ian/.local/share/pandoc on my machine. Currently pandocomatic is failing to find this file and associated templates:

~/Desktop/workflow-mmd via πŸ’Ž v2.7.1 
➜ pandocomatic --debug Workflow.md
No such template: 'docx'.

This used to compile without issue. If I deliberately specify the absolute path to that file, then it can use the template, but then fails to find the filters (which are also relative to the pandoc data directory):

~/Desktop/workflow-mmd via πŸ’Ž v2.7.1 
➜ pandocomatic -c ~/.local/share/pandoc/pandocomatic.yaml --debug Workflow.md
pandoc  --from=markdown \
    --to=docx \
    --standalone \
    --filter=/Users/ian/Desktop/workflow-mmd/filters/prependAll.rb \
    --filter=/Users/ian/Desktop/workflow-mmd/filters/simplifyMetadata.rb \
    --reference-doc=/Users/ian/Desktop/workflow-mmd/templates/custom.docx \
    --output=/Users/ian/Desktop/workflow-mmd/Workflow.docx
Error running filter /Users/ian/Desktop/workflow-mmd/filters/prependAll.rb:
Could not find executable /Users/ian/Desktop/workflow-mmd/filters/prependAll.rb
Error running pandoc => error while running:

pandoc  --from=markdown \
    --to=docx \
    --standalone \
    --filter=/Users/ian/Desktop/workflow-mmd/filters/prependAll.rb \
    --filter=/Users/ian/Desktop/workflow-mmd/filters/simplifyMetadata.rb \
    --reference-doc=/Users/ian/Desktop/workflow-mmd/templates/custom.docx \
    --output=/Users/ian/Desktop/workflow-mmd/Workflow.docx

Pandoc responded with:

Error running filter /Users/ian/Desktop/workflow-mmd/filters/prependAll.rb:
Could not find executable /Users/ian/Desktop/workflow-mmd/filters/prependAll.rb

In pandocmatic.yaml, the filter paths are specified thus:

  docx:
    pandoc:
      from: markdown
      to: docx
      standalone: true
      filter:
        - filters/prependAll.rb # prepends institute:, comments: and keywords: metadata into the text
        - filters/simplifyMetadata.rb #collapse down metadata "author: [name: affiliation:]" to author:
      reference-doc: templates/custom.docx

Deliberately forcing the data-dir to the default and it works:

~/Desktop/workflow-mmd via πŸ’Ž v2.7.1 via πŸ…’ base
➜ pandocomatic -d /Users/ian/.local/share/pandoc --debug Workflow.md
pandoc  --from=markdown \
    --to=docx \
    --standalone \
    --filter=/Users/ian/.local/share/pandoc/filters/prependAll.rb \
    --filter=/Users/ian/.local/share/pandoc/filters/simplifyMetadata.rb \
    --reference-doc=/Users/ian/.local/share/pandoc/templates/custom.docx \
    --output=/Users/ian/Desktop/workflow-mmd/Workflow.docx
Pandocomatic needed 1.1 seconds to convert '/Users/ian/Desktop/workflow-mmd/Workflow.md' to 'Workflow.docx'.

But we never used to need to specify this before, this is probably due to the changes you made for #81?


---pandoc: /usr/local/bin/pandoc | V: 2.10
---pandocomatic: /Users/ian/.rbenv/shims/pandocomatic | V: 0.2.7.2
---ruby: /Users/ian/.rbenv/shims/ruby | V: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
iandol commented 4 years ago

Hm very strange, if I revert back to V0.2.6 of pandocomatic (which is before those path changes I think), it still doesn't work! Perhaps this is local problem on this machine, but can't test that right now...

iandol commented 4 years ago

I also confirmed this on a different machine (both are macOS). On the second machine, it seemed to occur after updating to Pandoc 2.10, I didn't have time to try to roll back and test again, sorry.

htdebeer commented 4 years ago

I can reproduce the issue here as well. The issue is with a comparison with pando's version in paru/pandoc.rb. I now compare with the string "2.7", and that goes wrong with version 2.10….

I'll create a fix.

htdebeer commented 4 years ago

Fixed in paru 0.4.1.2

iandol commented 4 years ago

Thanks Huub!