【问题标题】:Pandoc doesn't seem to use settings in docx templatePandoc 似乎没有使用 docx 模板中的设置
【发布时间】:2021-08-07 20:31:07
【问题描述】:

我正在使用 Pandoc v1.12.2.1 将 html 转换为 docx。它通常可以工作,但我试图让它在docx 模板文件中读取,所以我可以告诉它使用 Arial 作为字体并将所有标题设为黑色(而不是蓝色,因为它们在瞬间)。

模板文件在

/path/to/my/project/public/pandoc/templates/reference.docx

我这样称呼 Pandoc:

pandoc --data-dir /path/to/my/project/public/pandoc --template reference.docx -s "$input" -o "$output"

$input$output 分别是我正在读取的 html 文件和生成的 docx 文件的目标位置。

它会生成一个docx 文件,但它没有考虑我的模板 - 它看起来与我不使用模板文件时相同。我认为它正在读取reference.docx 文件,因为如果我更改文件名,它会抱怨它不存在。

为了生成模板,我按照 [https://pandoc.org/MANUAL.html#option--reference-doc][1] 上的说明获取了由 Pandoc 生成的 docx 文件,编辑样式设置,然后保存。

我已将模板文件放在 [此处][2] 以防任何人发现其中有任何问题。

我正在尝试在 Ubuntu 14.04 中使用 LibreOffice 执行此操作,我想知道这是否与它无法正常工作有关?我需要在 Windows 中的 Microsoft Word 中编辑模板吗?

感谢任何建议。

编辑 - 我也试过这个:

pandoc "$input" -s --reference-docx /path/to/my/project/public/pandoc/templates/reference.docx  -o "$output"
``

and have the same result:  it doesn't seem to use the styles, but it will complain if I change the filename, suggesting that it is reading the doc.


  [1]: https://pandoc.org/MANUAL.html#option--reference-doc
  [2]: https://www.dropbox.com/s/e4dl9avue1i7vkr/reference.docx?dl=1

【问题讨论】:

    标签: docx pandoc file-conversion


    【解决方案1】:

    Pandoc 1.x 期望参考文档通过--reference-docx 命令行参数传递。从概念上讲,参考文档与模板不同,因为后者允许使用条件和变量替换。不同的命令行标志用于使差异更容易识别。

    请注意,如果您升级到更新的 pandoc 版本,pandoc 2.0 及更高版本将使用 --reference-doc 代替(没有 x)。

    【讨论】:

    • 谢谢 - 我刚刚看到阅读手册页很有趣。它也不起作用。我会在我的问题中添加一个关于它的编辑。
    • 抱歉,那我没办法了。也许那时的支持还不完整。也许使用newer version 会得到更好的结果。
    【解决方案2】:

    简短的回答是“在 Windows 中执行”。我将模板通过电子邮件发送到我的 Windows 笔记本电脑,将 docx 加载到 Windows 10 中的 Word 中,更新其中的样式,然后通过电子邮件将其发回给自己并在 Linux 中使用,它立即生效。

    因此,与 Windows 保存 docx 样式表的方式相比,LibreOffice 保存 docx 样式表的方式肯定有所不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 2023-03-14
      • 2021-08-30
      相关资源
      最近更新 更多