| 1 | !! |
| 2 | : ${1:?Usage: readtime.html path} |
| 3 | |
| 4 | words="$(awk ' |
| 5 | BEGIN { 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)" |
| 19 | rate=200 # wpm |
| 20 | |
| 21 | # round up the number of minutes |
| 22 | minutes=$(( (words + (rate - 1)) / rate )) |
| 23 | |
| 24 | if [ $minutes -ge 60 ]; then |
| 25 | hours=$(( minutes / 60 )) |
| 26 | minutes=$(( minutes % 60 )) |
| 27 | time="$hours hour and $minutes minute" |
| 28 | else |
| 29 | time="$minutes minute" |
| 30 | fi |
| 31 | !! |
| 32 | |
| 33 | <p><small><b>${time} read</b></small></p> |
| 34 | |