Commit: a7f55c77486105538352d06edeb981bdeade4049 Parent: 563658bd9eaadfecbeb7a3cbf47ccba0b2954fa7 Author: Johannes Thyssen Tishman Date: Mon, 17 Feb 2025 15:07:33 +0000 Add texref script Diffstat: A texref | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+), 0 deletions(-)
diff --git a/texref b/texref @@ -0,0 +1,53 @@ +#!/usr/bin/awk -f + +# Parse and print bibtex database entries. + +BEGIN { + FS = "[{}]"; + N = 0; + + BIBS[N,"type"] = "TYPE"; + BIBS[N,"label"] = "LABEL"; + BIBS[N,"author"] = "AUTHOR"; + BIBS[N,"title"] = "TITLE"; + + W["type"] = length(BIBS[N,"type"]); + W["label"] = length(BIBS[N,"label"]); + W["author"] = length(BIBS[N,"author"]); + W["title"] = length(BIBS[N,"title"]); +} + +/^@/ { + N++; + + width = length($1)-1; + BIBS[N,"type"] = substr($1, 2); + W["type"] = W["type"] < width ? width : W["type"]; + + width = length($2)-1; + BIBS[N,"label"] = substr($2, 1, width); + W["label"] = W["label"] < width ? width : W["label"]; +} + +/^[[:blank:]]*[Aa]uthor/ { + width = length($2); + BIBS[N,"author"] = $2; + W["author"] = W["author"] < width ? width : W["author"]; +} + +/^[[:blank:]]*[Tt]itle/ { + width = length($2); + BIBS[N,"title"] = $2; + W["title"] = W["title"] < width ? width : W["title"]; +} + +END { + for (i = 0; i < N; i++) + { + printf("%-*s %-*s %-*s %-*s \n", \ + W["type"], BIBS[i,"type"], \ + W["label"], BIBS[i,"label"], \ + W["author"], BIBS[i,"author"], \ + W["title"], BIBS[i,"title"]); + } +}