-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathomml2docx
More file actions
executable file
·30 lines (30 loc) · 690 Bytes
/
omml2docx
File metadata and controls
executable file
·30 lines (30 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# ./omml2docx nameofdocx.docx first.omml second.omml ...
target=$1
shift
cp math-template.docx "$target"
rm -rf tmp
unzip -q -d tmp "$target"
cd tmp
doc=word/document.xml
cat >$doc <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<w:body>
EOF
# skip top line <?xml...
for i in "$@"
do
echo "<w:p><w:r><w:t>$i</w:t></w:r></w:p><w:p>" >> $doc
grep -v '[<][?]xml version' ../$i >>$doc
echo "</w:p>" >> $doc
done
cat >>$doc <<EOF
</w:body>
</w:document>
EOF
zip -q -r ../"$target" $doc
cd ..
rm -rf tmp
echo "Created $target"