Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser authored Aug 13, 2021
1 parent 087425c commit 23e9380
Show file tree
Hide file tree
Showing 2 changed files with 937 additions and 478 deletions.
30 changes: 24 additions & 6 deletions count-bibliography.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ input="$*"
csl="$alfred_preferences""/workflows/""$alfred_workflow_uid""/citation-styles/""$csl_file"
bib=~`echo -n $bibtex_library_path | sed -e "s/~//"`

# Bibliography only
grep -Eo "[[^]]*@[^]]*]" $input > citationsOnly.txt
echo "πŸ’Ÿ" >> citationsOnly.txt

pandoc --citeproc --read=markdown --write=plain --csl $csl --bibliography $bib citationsOnly.txt | tr -d "\n" | cut -d "πŸ’Ÿ" -f 2 > referencesOnly.txt
words=`wc -w referencesOnly.txt | grep -Eo "[[:digit:]]+"`
chars=`wc -m referencesOnly.txt | grep -Eo "[[:digit:]]+"`
chars_without_spaces=`cat referencesOnly.txt | tr -d " " | wc -m | tr -d " "`
rm citationsOnly.txt referencesOnly.txt
bib_words=`wc -w referencesOnly.txt | grep -Eo "[[:digit:]]+"`
bib_chars=`wc -m referencesOnly.txt | grep -Eo "[[:digit:]]+"`
bib_chars_without_spaces=`cat referencesOnly.txt | tr -d " " | wc -m | tr -d " "`

# Total Draft
pandoc --citeproc --read=markdown --write=plain --csl $csl --bibliography $bib $input -o total.txt
total_words=`wc -w total.txt | grep -Eo "[[:digit:]]+"`
total_chars=`wc -m total.txt | grep -Eo "[[:digit:]]+"`
total_chars_without_spaces=`cat total.txt | tr -d " " | wc -m | tr -d " "`
rm citationsOnly.txt referencesOnly.txt total.txt

# Output
echo "✍️ Bibliography only"
echo "β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”"
echo $bib_words "words"
echo $bib_chars "characters"
echo "("$bib_chars_without_spaces" without spaces)"
echo ""
echo "πŸ““ Draft Total"
echo "β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”"
echo $total_words "words"
echo $total_chars "characters"
echo "("$total_chars_without_spaces" without spaces)"

echo ""$words" words\n"$chars" characters\n("$chars_without_spaces" without spaces)"
Loading

0 comments on commit 23e9380

Please sign in to comment.