Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile for pandoc with references file

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?

like image 986
Puzzled79 Avatar asked Sep 10 '12 01:09

Puzzled79


1 Answers

pandoc -s --smart --bibliography $*.bib -f markdown -o $@ $<
like image 88
Beta Avatar answered Sep 19 '22 15:09

Beta