Thumbnail

rani/buni.party.git

Clone URL: https://git.buni.party/rani/buni.party.git

Viewing file on branch master

1!!
2: ${1:?Usage: readtime.html path}
3
4words="$(awk '
5BEGIN { skip = 0 }
6
7/^!!.+$/ { next }
8
9/^!!$/ {
10 skip = !skip
11 next
12}
13
14!skip {
15 gsub(/<[^>]*>/ , "")
16 if (NF) print
17}
18' "$1" | wc -w)"
19rate=200 # wpm
20
21# round up the number of minutes
22minutes=$(( (words + (rate - 1)) / rate ))
23
24if [ $minutes -ge 60 ]; then
25 hours=$(( minutes / 60 ))
26 minutes=$(( minutes % 60 ))
27 time="$hours hour and $minutes minute"
28else
29 time="$minutes minute"
30fi
31!!
32
33<p><small><b>${time} read</b></small></p>
34