Can I specify command line options in a Pandoc Markdown document?

三世轮回 提交于 2020-01-17 06:43:43

问题


Sometimes, a *.md file requires (due to its content) a certain set of command line options regardless of the desired output format or of other, more optional command line options. E.g., when the document contains pandoc-fignos-style figure markup, --filter pandoc-fignos will always be required when wanting meaningful non-intermediate output.

Instead of having to remember which of my Pandoc documents requires what options, can I declare arbitrary command line options within the file itself, e.g. inside the YAML metadata? Or is there a corresponding metadatafield for each and every option that I could set instead. (If the latter, how can I find out about those field, e.g., what would be the corresponding field to --filter?)

I'm using pandoc 1.16.0.2 from the Ubuntu 16.04 xenial apt repo, but could switch to a later version if necessary.

Possible duplicates

  • This answer to Can I set command line arguments using the YAML metadata says something like this is possible with panzer, a wrapper around pandoc. But that was two years ago and another answer to that question mentions that some changes in that regard were planned in pandoc:

    The trouble with this solution [setting template-specific variables in the YAML] is that it only works with some output format. I thought I had read somewhere on the pandoc mailing-list that we soon would be able to use metadata in YAML blocks as intended (ie. as arguments rather than variables), but I can't find it anymore, so maybe it won't happen very soon.

    So I'm wondering whether pandoc itself can do this now.

  • Answers to What can I control with YAML header options in pandoc? go into how to find out what variables pandoc templates accepts. Though they don't mention whether anything in pandoc besides templates (which are AFAIK orthogonal to e.g. filter selection) can be controlled by the YAML block. (They might imply "No", but as they're from back in 2014 that could have changed by now.)

回答1:


As of pandoc 2.3, this is still not possible. See the issue tracking this request. Conceptually, pandoc would have to look at the YAML twice to do that, so it's unlikely this will be implemented.

However, you can use any of the following wrappers:

  • panrun minimal, no-dependencies script
  • panzer
  • pandocomatic


来源:https://stackoverflow.com/questions/43629039/can-i-specify-command-line-options-in-a-pandoc-markdown-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!