summaryrefslogtreecommitdiff
path: root/support/latex2nemeth/contrib/nemeth2odt
blob: 9777f9322f42cea119c604a32cf94f7ab121897a (plain)
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/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