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
26
27
28
|
# bib-canon.awk - canonical output helpers for bibutils
#
# Requires bib-parse.awk. Provides bib_emit() to print the current
# entry in canonical form, and bib_get() to look up a field value.
# print the current entry canonically: lowercase type and field names,
# 2-space indent, brace-delimited values with whitespace collapsed
function bib_emit(type, key, j, v) {
printf "@%s{%s,\n", type, key
for (j = 1; j <= BIB_N; j++) {
v = BIB_VAL[j]
if (BIB_KIND[j] == "s") {
gsub(/[ \t\r\n]+/, " ", v)
v = bib_trim(v)
printf " %s = {%s},\n", BIB_NAME[j], v
} else
printf " %s = %s,\n", BIB_NAME[j], v
}
print "}"
}
# value of field `name` (lowercase) in the current entry, "" if absent
function bib_get(name, j) {
for (j = 1; j <= BIB_N; j++)
if (BIB_NAME[j] == name)
return BIB_VAL[j]
return ""
}
|