Recfile Bibliography for TeX
Store your bibliography in a recfile database, then extract any part with make.
For example, you could store books like this in bibliography.rec:
%rec: book
%key: slug
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
Run make book to extract book.bib, ready for LaTeX to use:
1@book{thinkingexperience,
2 author = {H. H. Price},
3 title = {Thinking and Experience},
4 year = {1953},
5 publisher = {Harvard University Press, Cambridge},
6}
7
8@book{inventingrightwrong,
9 author = {John Leslie Mackie},
10 title = {Inventing Right and Wrong},
11 year = {1997},
12 publisher = {Penguin Books, England},
13}
The makefile syntax is just a few lines (though admittedly employs some garbled shell-crud):
1bibs != grep -Po '%rec: \K.*' bibliography.rec
2bibfiles = $(patsubst %, %.bib, $(bibs))
3
4$(bibfiles): %.bib: bibliography.rec
5 recsel $< -t $(basename $@) |\
6 sed 's/slug: \(.*\)/@$(basename $@){\1,/g' |\
7 sed 's/^\(\b.*\b\): \(.*\)/ \1 = {\2},/gI' |\
8 sed 's/^$$/}\n/g' > $@
9 echo '}' >> $@
Here's a longer bibliography.rec file, which can also produce article.bib:
%rec: book
%key: slug
%type: year int
%constraint: year > -2000
%sort: year month
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
slug: metaphysicscontemporaryintro
author: Michael J. Loux
title: Metaphysics: A Contemporary Introduction
year: 1998
publisher: Routledge, London
slug: pluralityworlds
author: David Lewis
title: On the Plurality of Worlds
publisher: Blackwell Publishing, Oxford
year: 2001
%rec: article
%key: slug
%sort: year month
slug: genuinerealisttheory
author: John Divers
title: A Genuine Realist Theory of Advanced Modalizing
year: 1999
pages: 217–240
month: april
journaltitle: Mind
uri: https://academic.oup.com/mind/article-abstract/108/430/217/975258?redirectedFrom=fulltext
volume: 108
publisher: Harvard University Press, Cambridge
slug: twokindsmentalrealism
author: Tam\'{a}s Demeter
title: Two Kinds of Mental Realism
year: 2009
pages: 40:59-71
uri: https://www.researchgate.net/profile/Tamas_Demeter2/publication/41554923_Two_Kinds_of_Mental_Realism/links/0deec53247f5a4ae21000000.pdf
month: august
journaltitle: Journal for General Philosophy of Science
volume: 30
publisher: Harvard University Press, Cambridge