My collection of scientific articles is managed primarily through BibTeX. While this works well with LaTeX, it's a pain with about everything else, e.g., writing a scientific text (with references) in plain text.
I have designed a scheme to produce the list of references in this way from the BibTeX database.
The idea is that, in the text, references are indexed with their BibTeX key in my format of name-of-first-author⇿two-last-digits-of-year-of-publication⇿$\alpha$ with $\alpha$ a letter to lift same-author-same-year degeneracy. So an extract could look like this (it could be unicode):
References can be indicated like this [blas11a,kol08a] or like this [blas11a;kol08a] or with space after the delimiter [blas11a, kol08a], etc. (but check the convention you want works).
The sequences of scripts will produce the following list to put at the end:
[bekenstein03a] J. D. Bekenstein. Information in the holographic universe. Sci. Am., 289:58, 2003. [ http://dx.doi.org/10.1038/scientificamerican0803-58 ] [blas11a] D. Blas, O. Pujolàs, and S. Sibiryakov. Models of non-relativistic quantum gravity: the good, the bad and the healthy. J. High Energ. Phys., 2011:18, 2011. [ http://dx.doi.org/10.1007/jhep04(2011)018 ] [kol08a] B. Kol and M. Smolkin. Non-relativistic gravitation: from Newton to Einstein and back. Class. Quantum Grav., 25:145011, 2008. [ http://dx.doi.org/10.1088/0264-9381/25/14/145011 ]
First create the references.txt ASCII file from the html files, themselves produced by genbib:
html2text -width 10000 ~/bib/sci.html > references.txt
html2text -width 10000 ~/bib/arXiv.html >> references.txt
The first extract the citations with:
extract_citation.sh
This wait for you to copy/paste the input. When you do so with the text above, it returns:
bekenstein03a blas11a kol08a
Then, use:
expand_refs.sh
to which you feed the above, and it'll return the ASCII list shown previously.
#!/bin/bash
# _____ _ _ ____ _ _ _ _
#| ____|_ _| |_ _ __ __ _ ___| |_ / ___(_) |_ __ _| |_(_) ___ _ __
#| _| \ \/ / __| '__/ _` |/ __| __| | | | __/ _` | __| |/ _ \| '_ \
#| |___ > <| |_| | | (_| | (__| |_| |___| | || (_| | |_| | (_) | | | |
#|_____/_/\_\\__|_| \__,_|\___|\__|\____|_|\__\__,_|\__|_|\___/|_| |_|
# F.P. Laussy - v0°3 Tue Dec 15 2025
# https://laussy.org/wiki/Poormanbib
#
# Extracts academic citation keys from text, supporting:
# - Standard: [smith12a], [jones05b,key07c]
# - arXiv-prefixed: [arXiv_smith12a], [arxiv_jones05b], [arXiv_key07c,laussy04d]
#
# Outputs one unique key per line, sorted alphabetically.
# The prefix "arXiv_" or "arxiv_" is stripped in the output.
cat | grep -oP '\b(arXiv_|arxiv_)?[a-zA-Z]+[0-9]{2}[a-zA-Z]\b' | \
sed 's/^(arXiv_|arxiv_)//' | \
grep -v '^$' | \
sort -u
#!/bin/bash
# _____ _ ____ __
#| ____|_ ___ __ __ _ _ __ __| | | _ \ ___ / _|___
#| _| \ \/ / '_ \ / _` | '_ \ / _` | | |_) / _ \ |_/ __|
#| |___ > <| |_) | (_| | | | | (_| | | _ < __/ _\__ \
#|_____/_/\_\ .__/ \__,_|_| |_|\__,_|___|_| \_\___|_| |___/
# F.P.Laussy|_| expand_refs.sh |_____|
# v0°5 - Tue Dec 15 2025
#
# Usage:
# ./expand_refs.sh
# → Type or paste your reference keys (one per line)
# → Press Ctrl-D when done
# The file references.txt is built independently, it must contain the key
REF_FILE="references.txt"
if [[ ! -f "$REF_FILE" ]]; then
echo "Error: '$REF_FILE' not found in the current directory." >&2
exit 1
fi
if [[ -t 0 ]]; then
echo "Enter your reference keys (one per line)." >&2
echo "When done, press Enter then Ctrl-D." >&2
echo >&2
fi
keys=()
while IFS= read -r key || [[ -n "$key" ]]; do
key="${key#"${key%%[![:space:]]*}"}"
key="${key%"${key##*[![:space:]]}"}"
[[ -z "$key" ]] && continue
keys+=("$key")
done
# Two non-breaking spaces
NBSP2=$'\u00A0\u00A0'
for key in "${keys[@]}"; do
match=$(grep "sci/${key}" "$REF_FILE")
if [[ -z "$match" ]]; then
echo "Error: No reference found for key '$key'." >&2
continue
fi
echo "$match" | sed -e "
s/^[[:space:]]*// # remove leading whitespace
s/^\[\([0-9]\+\)\]/[${key}]/ # replace [number] → [key] (no space inside)
s/$'\u00A0'/ /g # convert existing NBSP to regular spaces
s/|[[:space:]]*sci\/${key}[[:space:]]*\]*//g # remove the | sci/key part and any trailing ]
s/\][[:space:]]*\]/]/g # collapse any duplicate closing brackets ]]
s/\s\+/ /g # collapse multiple regular spaces to one in the main text
# s/ \[ / [${NBSP2}/ # start of DOI bracket: replace ' [' with '[two NBSP'
s/ \[ / [ / # start of DOI bracket: replace ' [' with '[two NBSP'
s/ \]/${NBSP2}]/ # end of DOI bracket: replace ' ]' with 'two NBSP]'
s/ / /
"
echo
done
if [[ -t 0 ]]; then
echo "Done." >&2
fi