IsraelTorres

w3cgoog.sh

Apr 15th, 2012
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. :<<israeltorres_comment_block
  3.  
  4. ./w3cgoog.sh
  5. Israel Torres
  6. 2012-04-15
  7. modify google docs exported html to be w3c compliant to stdout
  8.  
  9. Mac OS X 10.7.3 11D50d
  10. Darwin Kernel Version 11.3.0
  11. GNU bash, version 3.2.48(1)-release
  12.  
  13. israeltorres_comment_block
  14.  
  15. #required app check
  16. rqdapp='sed'
  17. hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - aborting"; exit 1; }
  18. #
  19.  
  20. if [ ! $# -ne 1 ]; then
  21. WEBFILE=$1
  22. TEMPLATE1='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
  23. TEMPLATE2='\<html\>\<head\>'
  24. TEMPLATE3='<meta http-equiv="Content-Type" content="text\/html; charset=utf-8">'
  25. echo -n "$TEMPLATE1" | cat - $WEBFILE | sed "s/$TEMPLATE2/$TEMPLATE2$TEMPLATE3/"
  26.  
  27. else
  28. echo "usage: $0 'google-exported-file.html'"
  29. echo "example: $0 google-exported-file.html"
  30. fi
  31. #eof
RAW Paste Data