format_xml.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. export LANG=zh_CN.UTF-8@cjknarrow
  2. git config core.quotepath 0
  3. # /usr/bin/find 策划脚本 -name '*.xml' | xargs sed -b -i \
  4. git diff --name-only HEAD 策划脚本| grep '\.xml$'|xargs sed -b -i \
  5. -e '/^ *<Active\(Sheet\|Row\|Col\)>/d' \
  6. -e '/^ *<\(TopRowBottom\|LeftColumnRight\)Pane>/d' \
  7. -e '/^ *<Selected\/>/d' \
  8. -e '/^ *<Window\(Height\|Width\|TopX\|TopY\)>/d' \
  9. -e '/^ *<\(Last\)*Author>/d' \
  10. -e '/^ *<TopRowVisible/d' \
  11. -e '/^ *<LastSaved/d' \
  12. -e '/^ *<LeftColumnVisible/d' \
  13. -e '/<Panes>/,/<\/Panes>/d' \
  14. -e '/<Table */,/>/s/ ss:StyleID="\w\+"//' \
  15. -e '/<Column .*\/>/d' \
  16. -e '/<Column /,/\/>/d' \
  17. -e '/<ConditionalFormatting xmlns/,/<\/ConditionalFormatting>/d' \
  18. -e '/<WorksheetOptions xmlns/,/<\/WorksheetOptions>/d' \
  19. -e '/^ *<Cell[ >]/s/ ss:StyleID="\w\+"//g' \
  20. -e '/^ *<Cell /,/<\/Cell>/s/ ss:StyleID="\w\+"//g' \
  21. -e '/^ *<Row /s/\( ss:StyleID=\)"\w\+"/\1"s1"/g' \
  22. -e '/^ *<Split/d'
  23. # /usr/bin/find 策划脚本 -name '*.xml' | xargs sed -b -i \
  24. git diff --name-only HEAD 策划脚本| grep '\.xml$'|xargs sed -b -i \
  25. -e '/^ *<\/Table>/a<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">'\
  26. '<Unsynced\/> <FrozenNoSplit\/> <SplitHorizontal>3<\/SplitHorizontal> <TopRowBottomPane>3<\/TopRowBottomPane> <SplitVertical>1<\/SplitVertical>'\
  27. '<LeftColumnRightPane>1<\/LeftColumnRightPane> <ActivePane>0<\/ActivePane>'\
  28. '\n<\/WorksheetOptions>'
  29. # /usr/bin/find 策划脚本 -name '*.xml' | while read n;
  30. git diff --name-only HEAD 策划脚本| grep '\.xml$'| while read n ;
  31. do
  32. awk -f style.awk "$n" > awk.tmp
  33. mv awk.tmp "$n"
  34. done