aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile31
-rw-r--r--freebsd/Makefile.in11
-rw-r--r--macports/Portfile.in9
-rw-r--r--man/man1/markdown2odt.1.md52
-rw-r--r--wrappers/markdown2odt.in41
5 files changed, 134 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index c3f821460..d0935746d 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ BUILDDIR := dist
BUILDCONF := $(BUILDDIR)/setup-config
BUILDVARS := vars
CONFIGURE := configure
+ODTSTYLES := odt-styles
#-------------------------------------------------------------------------------
# Cabal constants
@@ -23,7 +24,7 @@ EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:\{0,1\}[[:space:]]*//p' $(CABAL))
#-------------------------------------------------------------------------------
# Install targets
#-------------------------------------------------------------------------------
-WRAPPERS := html2markdown markdown2pdf hsmarkdown
+WRAPPERS := html2markdown markdown2pdf hsmarkdown markdown2odt
# Add .exe extensions if we're running Windows/Cygwin.
EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
sed -ne 's/^cygwin.*$$/\.exe/p')
@@ -33,6 +34,7 @@ PROGS := $(EXECS) $(WRAPPERS)
MAIN := $(firstword $(EXECS))
DOCS := README.html README BUGS
MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
+ODTREF := $(ODTSTYLES)/reference.odt
#-------------------------------------------------------------------------------
# Variables to setup through environment
@@ -106,10 +108,21 @@ awk ' \
chmod +x $@
endef
+cleanup_files+=$(ODTREF)
+$(ODTREF): $(addprefix $(ODTSTYLES)/, layout-cache meta.xml styles.xml content.xml mimetype \
+ settings.xml Configurations2 Thumbnails META-INF)
+ cd $(ODTSTYLES) ; \
+ zip -9 -r $(notdir $@) * -x $(notdir $@)
+
+ODTREFSH=$(SRCDIR)/wrappers/odtref.sh
+cleanup_files+=$(ODTREFSH)
+$(ODTREFSH): $(ODTREF)
+ echo "REFERENCEODT='$(PKGDATAPATH)/$(notdir $(ODTREF))'" > $@
+
.PHONY: wrappers
wrappers: $(WRAPPERS)
cleanup_files+=$(WRAPPERS)
-$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
+$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh $(ODTREFSH)
@$(generate-shell-script)
CABAL_BACKUP=$(CABAL).orig
@@ -179,7 +192,15 @@ install-doc: build-doc
uninstall-doc:
-for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
-for f in $(man_all); do rm -f $(MANPATH)/$$f; done
- rmdir $(PKGDOCPATH) $(PKGDATAPATH) 2>/dev/null ||:
+ rmdir $(PKGDOCPATH) 2>/dev/null ||:
+
+# Data file installation.
+.PHONY: install-data uninstall-data
+install-data: $(ODTREF)
+ $(INSTALL) -d $(PKGDATAPATH) && $(INSTALL_DATA) $(ODTREF) $(PKGDATAPATH)/
+uninstall-data:
+ -rm -f $(PKGDATAPATH)/$(notdir $(ODTREF))
+ rmdir $(PKGDATAPATH) 2>/dev/null ||:
# Program only installation.
.PHONY: install-exec uninstall-exec
@@ -197,8 +218,8 @@ uninstall-exec:
# Program + user documents installation.
.PHONY: install-program uninstall-program
-install-program: install-exec install-doc
-uninstall-program: uninstall-exec uninstall-doc
+install-program: install-exec install-data install-doc
+uninstall-program: uninstall-exec uninstall-doc uninstall-data
.PHONY: install-all uninstall-all
# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
diff --git a/freebsd/Makefile.in b/freebsd/Makefile.in
index 4db82edb7..2b4db29e0 100644
--- a/freebsd/Makefile.in
+++ b/freebsd/Makefile.in
@@ -16,17 +16,22 @@ COMMENT= A general markup converter
BUILD_DEPENDS= ghc>=6.6:${PORTSDIR}/lang/ghc
MANCOMPRESSED= no
-MAN1= pandoc.1 markdown2pdf.1 html2markdown.1 hsmarkdown.1
+MAN1= pandoc.1 markdown2pdf.1 html2markdown.1 hsmarkdown.1 markdown2odt.1
USE_GMAKE= yes
USE_PERL5= yes
-PLIST_FILES= bin/pandoc bin/markdown2pdf bin/html2markdown bin/hsmarkdown
+PLIST_FILES= bin/pandoc bin/markdown2pdf bin/html2markdown bin/hsmarkdown \
+ bin/markdown2odt
PORTDOCS= BUGS README README.html
-SCRIPTS= hsmarkdown html2markdown markdown2pdf
+SCRIPTS= hsmarkdown html2markdown markdown2pdf markdown2odt
+DATA_FILES= odt-styles/reference.odt
do-install:
@${INSTALL_PROGRAM} ${WRKSRC}/dist/build/pandoc/pandoc ${PREFIX}/bin
+.for f in ${DATA_FILES}
+ @${INSTALL_DATA} ${WRKSRC}/${f} ${DATADIR}
+.endfor
.for script in ${SCRIPTS}
@${INSTALL_SCRIPT} ${WRKSRC}/${script} ${PREFIX}/bin
.endfor
diff --git a/macports/Portfile.in b/macports/Portfile.in
index e352fe1b5..8ff8d2c63 100644
--- a/macports/Portfile.in
+++ b/macports/Portfile.in
@@ -40,13 +40,18 @@ destroot {
${destroot}${prefix}/libexec/${name}-${version}
# install shell scripts:
xinstall -m 755 -W ${worksrcpath} html2markdown hsmarkdown markdown2pdf \
- ${destroot}${prefix}/bin
+ markdown2odt ${destroot}${prefix}/bin
+ # install data file:
+ xinstall -d ${destroot}${prefix}/share/${name}
+ xinstall -m 644 -W ${worksrcpath} odt-styles/reference.odt \
+ ${destroot}${prefix}/share/${name}
# install user documentation and man pages:
xinstall -d ${destroot}${prefix}/share/doc/${name}
xinstall -m 644 -W ${worksrcpath} README README.html COPYRIGHT BUGS \
${destroot}${prefix}/share/doc/${name}
xinstall -m 644 -W ${worksrcpath}/man/man1 pandoc.1 hsmarkdown.1 \
- markdown2pdf.1 html2markdown.1 ${destroot}${prefix}/share/man/man1
+ markdown2pdf.1 html2markdown.1 markdown2odt.1 \
+ ${destroot}${prefix}/share/man/man1
}
post-activate {
diff --git a/man/man1/markdown2odt.1.md b/man/man1/markdown2odt.1.md
new file mode 100644
index 000000000..9325237f4
--- /dev/null
+++ b/man/man1/markdown2odt.1.md
@@ -0,0 +1,52 @@
+% MARKDOWN2ODT(1) Pandoc User Manuals
+% John MacFarlane and Recai Oktas
+% March 14, 2008
+
+# NAME
+
+markdown2odt - converts markdown-formatted text to ODT
+
+# SYNOPSIS
+
+markdown2odt [*options*] [*input-file*]...
+
+# DESCRIPTION
+
+`markdown2odt` converts *input-file* (or text from standard
+input) from markdown-formatted plain text to ODT (OpenDocument
+Text) format. If no output filename is specified (using the `-o`
+option), the name of the output file is derived from the input file;
+thus, for example, if the input file is *hello.txt*, the output file
+will be *hello.odt*. If the input is read from STDIN and no output
+filename is specified, the output file will be named *stdin.odt*. If
+multiple input files are specified, they will be concatenated before
+conversion, and the name of the output file will be derived from the
+first input file.
+
+Input is assumed to be in the UTF-8 character encoding. If your
+local character encoding is not UTF-8, you should pipe input
+through `iconv`:
+
+ iconv -t utf-8 input.txt | markdown2odt
+
+# OPTIONS
+
+`markdown2odt` is a wrapper around `pandoc`, so all of
+`pandoc`'s options can be used with `markdown2odt` as well.
+See `pandoc`(1) for a complete list.
+The following options are most relevant:
+
+-o *FILE*, \--output=*FILE*
+: Write output to *FILE*.
+
+\--strict
+: Use strict markdown syntax, with no extensions or variants.
+
+-S, \--smart
+: Use smart quotes, dashes, and ellipses. (This option is significant
+ only when the input format is `markdown`. It is selected automatically
+ when the output format is `latex` or `context`.)
+
+# SEE ALSO
+
+`pandoc`(1)
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 .
+
+