Makefile for pandoc with link file

I am 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 file name can be any .txt name. This part is simple. for example, I have a set of rules, for example:

 %.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 quotes from the same file as filename.bib . So, if I type make fudge.pdf , pandoc will convert fudge.txt to fudge.pdf by entering the bibtex links from fudge.bib. How can I do it? The command line is similar to

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

... but I cannot 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 the preprocessing in the * .bib file first (namely, create it and add the missing links), and b) set this macro on each line. Is there something more elegant?

+4
source share
1 answer
 pandoc -s --smart --bibliography $*.bib -f markdown -o $@ $< 
+6
source

Source: https://habr.com/ru/post/1433276/


All Articles