aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bib-ls.awk
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bib-ls.awk')
-rw-r--r--lib/bib-ls.awk25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bib-ls.awk b/lib/bib-ls.awk
new file mode 100644
index 0000000..909b654
--- /dev/null
+++ b/lib/bib-ls.awk
@@ -0,0 +1,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
+}