stagit-clean.sh (858B)
1 #!/bin/bash 2 3 style_root="./style.css" 4 5 clean_file() { 6 local file="$1" 7 if [ -f "$file" ]; then 8 echo "Processing $file" 9 10 sed -i 's#<td><img src="\([^"]*\)" alt="" width="32" height="32" /></td>##g' "$file" 11 sed -i 's#<link rel="icon" type="image/png" href="\([^"]*\)" />##g' "$file" 12 sed -i 's#<a href="\([^"]*\)"><img src="\([^"]*\)" alt="" width="32" height="32" /></a>##g' "$file" 13 14 relative_style_path=$(realpath --relative-to="$(dirname "$file")" "$style_root") 15 16 sed -i "s#<link rel=\"stylesheet\" type=\"text/css\" href=\".*style.css\" />#<link rel=\"stylesheet\" type=\"text/css\" href=\"$relative_style_path\" />#g" "$file" 17 else 18 echo "File $file not found, skipping." 19 fi 20 } 21 22 export -f clean_file 23 export style_root 24 25 find . -type f -name "*.html" -exec bash -c 'clean_file "$0"' {} \; 26