Вопрос

I'm trying to write a Makefile for pandoc. I want to be able to type make filename.ext and the Makefile will automatically compile from filename.txt to filename.ext. The filename could be anything named .txt. This part is easy. e.g. I have a set of rules like:

%.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 $@ $<

However, I also want to add citations from the same file called filename.bib. So, if I type make fudge.pdf, pandoc will convert fudge.txt to fudge.pdf while incorporating bibtex citations from fudge.bib. How do I do this? The command line is something like

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

... but I can't figure out how to get fudge.bib from fudge.txt without doing something like this:

pandoc -s --smart --bibliography $(subst .txt,.bib,$<) -f markdown -o $@ $<

This will work, but a) I want to do some preprocessing on the file *.bib first (namely generating it and adding missing references) and b) need that macro on every line. Is there anything more elegant?

Это было полезно?

Решение

pandoc -s --smart --bibliography $*.bib -f markdown -o $@ $<
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top