format_xml.sh 2.9 KB

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