gpt4 book ai didi

Pandoc的Makefile和引用文件

转载 作者:行者123 更新时间:2023-12-04 18:11:47 26 4
gpt4 key购买 nike

我正在尝试为pandoc编写Makefile。我希望能够键入make filename.ext,Makefile将自动从filename.txt编译为filename.ext。文件名可以是任何名为.txt的文件。这部分很容易。例如我有一组规则,例如:

%.pdf: %.txt
pandoc -s --smart -f markdown -o $@ $<

%.html: %.txt
pandoc -s --smart --bibliography $(bib) -f markdown -t html --standalone -o $@ $<

%.docx: %.txt
pandoc -s --smart --bibliography references.bib -f markdown -t docx -o $@ $<

%.tex: %.txt
pandoc -s --smart --bibliography references.bib -o $@ $<

但是,我也想从同一文件 filename.bib添加引用。因此,如果我键入 make fudge.pdf,则pandoc会将fudge.bib的bibtex引用合并到一起,将fudge.txt转换为fudge.pdf。我该怎么做呢?命令行类似于
pandoc -s --smart --bibliography filename.bib -f markdown -o $@ $<

...但是我不知道如何从fudge.txt中获取fudge.bib,而无需执行以下操作:
pandoc -s --smart --bibliography $(subst .txt,.bib,$<) -f markdown -o $@ $<

这将起作用,但是a)我首先要对文件* .bib进行一些预处理(即生成它并添加缺少的引用),并且b)每行都需要该宏。还有什么更优雅的吗?

最佳答案

pandoc -s --smart --bibliography $*.bib -f markdown -o $@ $<

关于Pandoc的Makefile和引用文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12344471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com