Created
December 6, 2019 21:55
-
-
Save Colelyman/49a70793895ec81027e6d0aff46a04e1 to your computer and use it in GitHub Desktop.
Generate a citation in Markdown from a BibTeX entry.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TEMP_BIB_PATH=".mybib.bib" | |
TEMP_MD_PATH=".mybib.md" | |
TEMP_CITATION_PATH=".mycitation.md" | |
clean() { | |
rm -rf $TEMP_BIB_PATH $TEMP_MD_PATH $TEMP_CITATION_PATH | |
} | |
clean | |
while read line | |
do | |
echo "$line" >> $TEMP_BIB_PATH | |
done < "${1:-/dev/stdin}" | |
cat > $TEMP_MD_PATH <<- EOF | |
--- | |
title: Citations | |
bibliography: $TEMP_BIB_PATH | |
nocite: '@*' | |
... | |
EOF | |
pandoc --filter=pandoc-citeproc -t markdown-citations --standalone $TEMP_MD_PATH | tail -n +9 > $TEMP_CITATION_PATH | |
cat $TEMP_CITATION_PATH | head -$(($(wc -l < $TEMP_CITATION_PATH) - 2)) $TEMP_CITATION_PATH | |
clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This depends on
pandoc
being installed.The BibTeX entry can be input from stdin or a file can be provided.