aboutsummaryrefslogtreecommitdiff
path: root/wrappers/markdown2odt.in
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/markdown2odt.in')
-rw-r--r--wrappers/markdown2odt.in41
1 files changed, 41 insertions, 0 deletions
diff --git a/wrappers/markdown2odt.in b/wrappers/markdown2odt.in
new file mode 100644
index 000000000..e5b3f0212
--- /dev/null
+++ b/wrappers/markdown2odt.in
@@ -0,0 +1,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 .
+
+