aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bib-ls.awk
blob: 909b65480bdcc02112d67bfe20e63cb757f67e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# bib-ls.awk - list database entries
#
# Requires bib-parse.awk and bib-canon.awk. Variables (set with -v):
#   long - 0: print one key per line
#          1: print key, type, author, year and title, tab-separated

function bib_pass(raw) { }

function bib_entry(type, key,    a, t) {
  if (long + 0 == 0) {
    print key
    return
  }
  a = bib_get("author")
  if (a == "")
    a = bib_get("editor")
  gsub(/[{}]/, "", a)
  gsub(/[ \t\r\n]+/, " ", a)
  if (match(a, / [Aa][Nn][Dd] /))
    a = substr(a, 1, RSTART - 1) " et al."
  t = bib_get("title")
  gsub(/[{}]/, "", t)
  gsub(/[ \t\r\n]+/, " ", t)
  printf "%s\t%s\t%s\t%s\t%s\n", key, type, a, bib_get("year"), t
}