| 1 |
# bibkey.sed |
| 2 |
# |
| 3 |
# Goes with bin/bibkey - look for a word in the keyword entry |
| 4 |
# |
| 5 |
# David Kotz ([email protected]) |
| 6 |
# |
| 7 |
# On stdin, we get a lowercased bibtex file with comments stripped. |
| 8 |
# |
| 9 |
# On stdout, we produce a list of line numbers that are the starting |
| 10 |
# line number of each reference, and the text of all "keyword" |
| 11 |
# entries on separate lines. |
| 12 |
|
| 13 |
# the idea is to get @ line numbers and all keywords |
| 14 |
# @ entry |
| 15 |
/^[ ]*@.*/= |
| 16 |
# one-line keyword entry |
| 17 |
s/[ ]*keyword[ ]*=[ ]*"\(.*\)".*/\1/p |
| 18 |
t |
| 19 |
# start of multi-line keyword entry |
| 20 |
s/[ ]*keyword[ ]*=[ ]*"\(.*\)/\1/ |
| 21 |
t partial |
| 22 |
b |
| 23 |
# Handle multi-line keyword entry: save this line, repeatedly add |
| 24 |
# lines until close quote forces output |
| 25 |
:partial |
| 26 |
N |
| 27 |
s/\(.*\n.*\)".*/\1/ |
| 28 |
t done |
| 29 |
b partial |
| 30 |
:done |
| 31 |
s/\n/ /g |
| 32 |
p |