summary refs log tree commit diff
path: root/doc/rfc/rfc.in
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-01-03 14:08:23 -0500
committerJune McEnroe <june@causal.agency>2022-01-03 14:08:23 -0500
commit62fb45e18ff493e576ddbf24b83d46d064760072 (patch)
tree368ea224bc9c96b39114f7b396e1853fd7da74e7 /doc/rfc/rfc.in
parentRemove sudo/doas from install script (diff)
downloadsrc-62fb45e18ff493e576ddbf24b83d46d064760072.tar.gz
src-62fb45e18ff493e576ddbf24b83d46d064760072.zip
Generate RFC bibliographic blocks from JSON
Diffstat (limited to 'doc/rfc/rfc.in')
-rw-r--r--doc/rfc/rfc.in22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/rfc/rfc.in b/doc/rfc/rfc.in
index 16081c83..abeb293f 100644
--- a/doc/rfc/rfc.in
+++ b/doc/rfc/rfc.in
@@ -4,6 +4,28 @@ set -eu
 mktemp='mktemp -t rfc'
 [ "$(uname)" = 'OpenBSD' ] && mktemp="${mktemp}.XXXXXXXXXX"
 
+bib=
+while getopts 'b:' opt; do
+	case $opt in
+		(b) bib=$OPTARG;;
+		(?) exit 1;;
+	esac
+done
+shift $((OPTIND - 1))
+
+if test -n "${bib}"; then
+	exec jq -r '
+		".Rs",
+		(.authors[] | ".%A \(.)"),
+		".%T \(.title | ltrimstr(" "))",
+		".%I IETF",
+		".%R \(.doc_id)",
+		".%U https://tools.ietf.org/html/\(.doc_id | ascii_downcase)",
+		".%D \(.pub_date)",
+		".Re"
+	' %%PREFIX%%/share/rfc/"rfc${bib}.json"
+fi
+
 rfc=%%PREFIX%%/share/rfc/"rfc${1:--index}.txt"
 tags=$($mktemp)
 trap 'rm "${tags}"' EXIT