#!/bin/bash # Shell script to add 'Copy' functionality to Offline HTML Indexer output # assuming use of the standalone Android app viewer. # Version 1.4, Silas S. Brown 2014-15, 2020-21, public domain, no warranty # OHI output must be in the current directory when run. # Also works with multiple OHI outputs in a non-merged # collection (subdirectories with a master index.html) # Where to find history: # on GitHub at https://github.com/ssb22/indexer # and on GitLab at https://gitlab.com/ssb22/indexer # and on BitBucket https://bitbucket.org/ssb22/indexer # and at https://gitlab.developers.cam.ac.uk/ssb22/indexer # and in China: https://gitee.com/ssb22/indexer if ! test -e index.html; then echo Wrong directory; exit 1; fi for N in [0-9]*.html; do if test -e "$N"; then python2 -c 'import sys,re ; sys.stdout.write(re.sub(u"([\u4e00-\ua6ff]([\u3000-\uffe0]*[\u4e00-\ua6ff])*)","\\1",sys.stdin.read().decode("utf-8")).encode("utf-8"))' < "$N" | sed -e 's,/script>,/script>,' > n && mv n "$N"; fi; done && for N in */[0-9]*.html; do if test -e "$N"; then python2 -c 'import sys,re ; sys.stdout.write(re.sub(u"([\u4e00-\ua6ff]([\u3000-\uffe0]*[\u4e00-\ua6ff])*)(?![^\"]*\">)","\\1",sys.stdin.read().decode("utf-8")).encode("utf-8"))' < "$N" | sed -e 's,/script>,/script>,' > n && mv n "$N"; fi; done && sed -e 's|