[英]Bash file redirection instead of string interpretation in Pandoc makefile
[英]Makefile for pandoc with references file
我正在嘗試為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.txt轉換為fudge.pdf,同時合並來自fudge.bib的bibtex引用。 我該怎么做呢? 命令行就像
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 $@ $<
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.