4
我正在尝试为pandoc编写一个Makefile。我希望能够输入make filename.ext
,Makefile将自动从filename.txt
编译为filename.ext
。文件名可以是任何名称为.txt的文件。这部分很简单。例如我有这样一套规则:用于参考文件的pandoc的Makefile
%.pdf: %.txt
pandoc -s --smart -f markdown -o [email protected] $<
%.html: %.txt
pandoc -s --smart --bibliography $(bib) -f markdown -t html --standalone -o [email protected] $<
%.docx: %.txt
pandoc -s --smart --bibliography references.bib -f markdown -t docx -o [email protected] $<
%.tex: %.txt
pandoc -s --smart --bibliography references.bib -o [email protected] $<
不过,我也想从所谓filename.bib
同一文件添加引用。因此,如果我输入make fudge.pdf
,则pandoc会将fudge.txt转换为fudge.pdf,同时包含来自fudge.bib的bibtex引用。我该怎么做呢?该命令行是一样的东西
pandoc -s --smart --bibliography filename.bib -f markdown -o [email protected] $<
...但我无法弄清楚如何从fudge.txt获得fudge.bib没有做这样的事情:
pandoc -s --smart --bibliography $(subst .txt,.bib,$<) -f markdown -o [email protected] $<
这将工作,但是a)我想先对文件* .bib进行一些预处理(即生成它并添加缺少的引用),并且b)在每一行上都需要该宏。有什么更优雅的?
完美,谢谢! – Puzzled79