summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/rfc/Makefile4
-rw-r--r--doc/rfc/rfc.19
-rw-r--r--doc/rfc/rfc.in22
3 files changed, 32 insertions, 3 deletions
diff --git a/doc/rfc/Makefile b/doc/rfc/Makefile
index 31e238a0..3078dcd3 100644
--- a/doc/rfc/Makefile
+++ b/doc/rfc/Makefile
@@ -1,8 +1,8 @@
 PREFIX ?= ~/.local
 MANDIR ?= ${PREFIX}/share/man
 
-MODULE = ftp.rfc-editor.org::rfcs-text-only
-RFCS = ${MODULE}/rfc-index.txt ${MODULE}/'rfc[1-9]*.txt'
+MODULE = ftp.rfc-editor.org::rfcs
+RFCS = ${MODULE}/rfc-index.txt ${MODULE}/'rfc[1-9]*.txt' ${MODULE}/'rfc*.json'
 
 all: rfc rfctags
 
diff --git a/doc/rfc/rfc.1 b/doc/rfc/rfc.1
index ece5a901..da393e8b 100644
--- a/doc/rfc/rfc.1
+++ b/doc/rfc/rfc.1
@@ -1,4 +1,4 @@
-.Dd January 18, 2021
+.Dd January  3, 2022
 .Dt RFC 1
 .Os
 .
@@ -10,6 +10,8 @@
 .Sh SYNOPSIS
 .Nm rfc
 .Op Ar number
+.Nm rfc
+.Fl b Ar number
 .Nm rfctags
 .Op Ar
 .
@@ -23,6 +25,11 @@ The RFC is displayed in the
 .Ev PAGER
 with a tags file generated by
 .Nm rfctags .
+The
+.Fl b
+option outputs an
+.Xr mdoc 7
+bibliographic block.
 .
 .Pp
 The
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