summaryrefslogtreecommitdiff
path: root/support/latex2nemeth/contrib/nemeth2odt
diff options
context:
space:
mode:
Diffstat (limited to 'support/latex2nemeth/contrib/nemeth2odt')
-rw-r--r--support/latex2nemeth/contrib/nemeth2odt30
1 files changed, 30 insertions, 0 deletions
diff --git a/support/latex2nemeth/contrib/nemeth2odt b/support/latex2nemeth/contrib/nemeth2odt
new file mode 100644
index 0000000000..9777f9322f
--- /dev/null
+++ b/support/latex2nemeth/contrib/nemeth2odt
@@ -0,0 +1,30 @@
+#!/bin/bash
+#get a random name first of 8 chars
+tmpdir=`cat /dev/urandom | tr -cd 'a-f0-9' | head -c 8`
+
+#make a folder
+mkdir $tmpdir
+
+#get the base name of the fole to convert
+file=`basename "$1" .nemeth`
+
+#convert nemeth from utf16 to utf8
+iconv -f utf-16 -t utf-8 "$1" > $file.txt
+
+#convert txt file to odt
+libreoffice --headless --convert-to odt $file.txt 1>/dev/null
+
+# odt is setup with a bultintemplate for convertions
+#from text, that uses Liberation Mono font.
+#we need DejaVu Serif. We change the font and repack
+#the odt file
+unzip -qq -d $tmpdir $file.odt
+rm -f $file.odt
+find $tmpdir -type f | xargs sed -i 's/Liberation Mono/DejaVu Serif/g'
+( cd $tmpdir; zip -qq -r ../$file.odt . )
+
+#cleanup
+/bin/rm -rf $tmpdir $file.txt
+
+
+