"
elif [[ ! -e "$1" ]]; then
error "$0: Directory \"$1\" not found"
fi
declare htmlPath=$1
declare flag="post-build-hide-empty-table-rows"
declare td="\n*[\n\s]* | \n*"
declare td_p=${td}
message "Cleaning up empty table rows in flagged files"
declare flagged_files=( $(grep -rl --include="*.html" "${flag}" ${htmlPath}) )
for _html in ${flagged_files[@]}; do
confirmation "... $_html"
sed -i -E -e ':a;N;$!ba;s/\n(<\/tr>)/\1/g' ${_html}
sed -i -E -e ':a;N;$!ba;s/\n(<\/td>+)(<\/tr>)/\1\2/g' ${_html}
# sed has no non-greedy mode
for i in {1..10}; do
sed -i -E "s:^ | ${td_p}
::g" ${_html}
td_p="$td_p$td"
done
# sed -i -E "s:^( | +)(
):\1\2:g" ${_html}
done
confirmation "... Done"