format_xml.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. export LC_ALL=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$'|grep -v -e 'items/Tc.xmld' -e 'monster/Monster.xmld'|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 's/Font html:Face="[^"]*"/Font/g' \
  13. -e '/^ *<FirstVisibleSheet/d' \
  14. -e '/^ *<LeftColumnVisible/d' \
  15. -e '/<Panes>/,/<\/Panes>/d' \
  16. -e '/<Styles>/,/<\/Styles>/d' \
  17. -e '/<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">/,/<\/CustomDocumentProperties>/d' \
  18. -e '/<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">/,/<\/OfficeDocumentSettings>/d' \
  19. -e '/<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">/,/<\/ExcelWorkbook>/d' \
  20. -e '/<Table */,/>/s/ ss:StyleID="\w\+"//' \
  21. -e '/<Table */,/>/s/ ss:ExpandedRowCount="[0-9]*"//' \
  22. -e '/<Column .*\/>/d' \
  23. -e '/<Column /,/\/>/d' \
  24. -e '/<ConditionalFormatting xmlns/,/<\/ConditionalFormatting>/d' \
  25. -e '/<WorksheetOptions xmlns/,/<\/WorksheetOptions>/d' \
  26. -e '/^ *<Cell[ >].*<\/Cell>/s/ ss:StyleID="\w\+"//g' \
  27. -e '/^ *<Cell .*[^C][^e][^l][^l]$/,/<\/Cell>/s/ ss:StyleID="\w\+"//g' \
  28. -e '/^ *<Table /,/<\/Table>/s/ x:CharSet="[0-9]\+"//g' \
  29. -e '/^ *<Row /s/\( ss:StyleID=\)"\w\+"//g' \
  30. -e '/^ *<Row /s/\( ss:Height="[0-9]\+\(\.[0-9]\+\)*\)"//g' \
  31. -e '/^ *<Split/d'
  32. git diff --name-only HEAD 策划脚本| grep '\.xml$'|xargs sed -b -i \
  33. -e '/^ *<Window\(Height\|Width\|TopX\|TopY\)>/d'
  34. # /usr/bin/find 策划脚本 -name '*.xml' | xargs sed -b -i \
  35. git diff --name-only HEAD 策划脚本| grep '\.xml$'|grep -v -e 'items/Tc.xmld' -e 'monster/Monster.xmld'|xargs sed -b -i \
  36. -e '/^ *<\/Table>/a<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">'\
  37. '<Unsynced\/> <FrozenNoSplit\/> <SplitHorizontal>3<\/SplitHorizontal> <TopRowBottomPane>3<\/TopRowBottomPane> <SplitVertical>1<\/SplitVertical>'\
  38. '<LeftColumnRightPane>1<\/LeftColumnRightPane> <ActivePane>0<\/ActivePane>'\
  39. '\n<\/WorksheetOptions>'
  40. # /usr/bin/find 策划脚本 -name '*.xml' | while read n;
  41. git diff --name-only HEAD 策划脚本| grep '\.xml$'|grep -v -e 'items/Tc.xmld' -e 'monster/Monster.xmld'| while read n ;
  42. do
  43. awk -f style.awk "$n" > awk.tmp
  44. mv awk.tmp "$n"
  45. done
  46. git diff --name-only HEAD 策划脚本| grep '\.xml$'|grep -v -e 'items/Tc.xmld' -e 'monster/Monster.xmld'|xargs sed -b -i \
  47. -e 's/ x:Family="[^"]*"//g' \
  48. -e 's/ss:Data ss:Type="String" xmlns="http:[^"]*">\(.*\)<\/ss:Data>/Data ss:Type="String">\1<\/Data>/g' \
  49. -e '/^ *<Cell[ >].*<\/Cell>/s/ ss:StyleID="\w\+"//g'