blob: e5b3f02127c1a81211bb71ddbcd57f640a8c05ce (
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
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/sh -e
REQUIRED="zip"
SYNOPSIS="converts markdown-formatted text to ODT."
### odtref.sh
### common.sh
### tempdir.sh
if [ "$OUTPUT" = "-" ]; then
firstinfile="$(echo $ARGS | sed -ne '1p')"
firstinfilebase="${firstinfile%.*}"
destname="${firstinfilebase:-stdin}.odt"
else
destname="$OUTPUT"
fi
(
cp $REFERENCEODT $THIS_TEMPDIR/new.odt
pandoc -s -r markdown -w opendocument "$@" -o $THIS_TEMPDIR/content.xml
zip -9 -j $THIS_TEMPDIR/new.odt $THIS_TEMPDIR/content.xml
) || exit $?
is_target_exists=
if [ -f "$destname" ]; then
is_target_exists=1
mv "$destname" "$destname~"
fi
mv -f $THIS_TEMPDIR/new.odt "$destname"
errn "Created $destname"
[ -z "$is_target_exists" ] || {
errn " (previous file has been backed up as $destname~)"
}
err .
|