#!/bin/sh
#
# Compute Flesch–Kincaid readability score on (HTML) page on stdin.
#
#     https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests
#
# Should produce an integer score up to 100 (good), eg:
#
# % script/rawHTML-readability < index.html
# 70
#
# Run reado directly to point out things that need improving.

# May be based on npm redo-cli:
#     http://npm.taobao.org/package/reado-cli

# Ensure that /usr/local/bin is on the PATH for 'node' at al.
. script/NPM.loc
PATH="$PATH:$NPMBIN"
export PATH

$NPMBIN/reado --unfluff | tail -4 | \
    awk '/^score:/ {if("NaN"==$2){print $2}else{print int($2)}; exit}'
