#!/bin/bash ## Split an HTML file into subsets -- for things formerly handled by hash-links; Eugene Reimer 2009; ## ## EXAMPLE: ## if about.htm contains the following A-NAME tags: ## ## ## ## then the commandline webmksubsets about.htm will produce the following subset-files: ## about-Memberships.htm ## about-Elist.htm ## about-CopyrightPolicy.htm ## with each containing everything from its A-NAME tag until the next such tag, and having a timestamp identical to the source-file's; BACKUP=1 while [ $# -gt 0 ] && [[ $1 == -* ]];do ##parse options case "$1" in -n|--nob*) BACKUP= ;; ##no-backup option --) shift; break ;; ##ender for options esac shift; ##remove arg done if [ $# -ne 1 ];then echo "Usage: webmksubsets [--nobackup] SOURCEFILE"; exit; fi export NMB=${1%.*} ##port HD=$(cat $1 |sed -n '0,//,/=nopercart.js/p' |tr '\n' '\v');fi ##save Shopping-Cart code (needed for noci shopping.htm) BKDIR=/tmp/bkmksubsets-$NMB if [ $BACKUP ];then mkdir -p $BKDIR; mv -fv $NMB-* $BKDIR; fi ##keep old versions as backups; and start with clean slate cat $1 |tr '\n' '\v' |sed 's|$TO ##note: the TITLE, HR, and H3-->H2 conventions touch --reference="$1" $TO ##make subset-file's timestamp be same as parent's done ##for S in $NMB-*;do [ -e $S ] && echo -e "\n\n==" && diffsed '0,/