git.iko.soy/typeable/pandoc
on master help sign in
Added preliminary version of markdown2odt wrapper.

Added man page. Modified Makefile to create markdown2odt from template. Modified Makefile to create reference.odt file from files in odt-styles. Modified Makefile to install reference.odt into PACKAGEDATAPATH. Modified macports Portfile. Modified freebsd Makefile. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1259 788f1e2b-df1e-0410-8736-df70ead52e1b

commit91d9fffe9e70a59bf37823670d8f975179f4d001 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateWed 19 Mar 2008, 18:46 (19 years ago) parent1cbcaa8
5 files changed+134−10
Makefile+26−5 freebsd/Makefile.in+8−3 macports/Portfile.in+7−2 man/man1/markdown2odt.1.md+52 wrappers/markdown2odt.in+41
Makefile+26−5
@@ -11,6 +11,7 @@ BUILDDIR := dist
1111BUILDCONF := $(BUILDDIR)/setup-config
1212BUILDVARS := vars
1313CONFIGURE := configure
14+ODTSTYLES := odt-styles
1415
1516#-------------------------------------------------------------------------------
1617# Cabal constants
@@ -23,7 +24,7 @@ EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:\{0,1\}[[:space:]]*//p' $(CABAL))
2324#-------------------------------------------------------------------------------
2425# Install targets
2526#-------------------------------------------------------------------------------
26−WRAPPERS := html2markdown markdown2pdf hsmarkdown
27+WRAPPERS := html2markdown markdown2pdf hsmarkdown markdown2odt
2728# Add .exe extensions if we're running Windows/Cygwin.
2829EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
2930 sed -ne 's/^cygwin.*$$/\.exe/p')
@@ -33,6 +34,7 @@ PROGS := $(EXECS) $(WRAPPERS)
3334MAIN := $(firstword $(EXECS))
3435DOCS := README.html README BUGS
3536MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
37+ODTREF := $(ODTSTYLES)/reference.odt
3638
3739#-------------------------------------------------------------------------------
3840# Variables to setup through environment
@@ -106,10 +108,21 @@ awk ' \
106108chmod +x $@
107109endef
108110
111+cleanup_files+=$(ODTREF)
112+$(ODTREF): $(addprefix $(ODTSTYLES)/, layout-cache meta.xml styles.xml content.xml mimetype \
113+ settings.xml Configurations2 Thumbnails META-INF)
114+ cd $(ODTSTYLES) ; \
115+ zip -9 -r $(notdir $@) * -x $(notdir $@)
116+
117+ODTREFSH=$(SRCDIR)/wrappers/odtref.sh
118+cleanup_files+=$(ODTREFSH)
119+$(ODTREFSH): $(ODTREF)
120+ echo "REFERENCEODT='$(PKGDATAPATH)/$(notdir $(ODTREF))'" > $@
121+
109122.PHONY: wrappers
110123wrappers: $(WRAPPERS)
111124cleanup_files+=$(WRAPPERS)
112−$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
125+$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh $(ODTREFSH)
113126 @$(generate-shell-script)
114127
115128CABAL_BACKUP=$(CABAL).orig
@@ -179,7 +192,15 @@ install-doc: build-doc
179192uninstall-doc:
180193 -for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
181194 -for f in $(man_all); do rm -f $(MANPATH)/$$f; done
182− rmdir $(PKGDOCPATH) $(PKGDATAPATH) 2>/dev/null ||:
195+ rmdir $(PKGDOCPATH) 2>/dev/null ||:
196+
197+# Data file installation.
198+.PHONY: install-data uninstall-data
199+install-data: $(ODTREF)
200+ $(INSTALL) -d $(PKGDATAPATH) && $(INSTALL_DATA) $(ODTREF) $(PKGDATAPATH)/
201+uninstall-data:
202+ -rm -f $(PKGDATAPATH)/$(notdir $(ODTREF))
203+ rmdir $(PKGDATAPATH) 2>/dev/null ||:
183204
184205# Program only installation.
185206.PHONY: install-exec uninstall-exec
@@ -197,8 +218,8 @@ uninstall-exec:
197218
198219# Program + user documents installation.
199220.PHONY: install-program uninstall-program
200−install-program: install-exec install-doc
201−uninstall-program: uninstall-exec uninstall-doc
221+install-program: install-exec install-data install-doc
222+uninstall-program: uninstall-exec uninstall-doc uninstall-data
202223
203224.PHONY: install-all uninstall-all
204225# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
freebsd/Makefile.in+8−3
@@ -16,17 +16,22 @@ COMMENT= A general markup converter
1616BUILD_DEPENDS= ghc>=6.6:${PORTSDIR}/lang/ghc
1717
1818MANCOMPRESSED= no
19−MAN1= pandoc.1 markdown2pdf.1 html2markdown.1 hsmarkdown.1
19+MAN1= pandoc.1 markdown2pdf.1 html2markdown.1 hsmarkdown.1 markdown2odt.1
2020
2121USE_GMAKE= yes
2222USE_PERL5= yes
2323
24−PLIST_FILES= bin/pandoc bin/markdown2pdf bin/html2markdown bin/hsmarkdown
24+PLIST_FILES= bin/pandoc bin/markdown2pdf bin/html2markdown bin/hsmarkdown \
25+ bin/markdown2odt
2526PORTDOCS= BUGS README README.html
26−SCRIPTS= hsmarkdown html2markdown markdown2pdf
27+SCRIPTS= hsmarkdown html2markdown markdown2pdf markdown2odt
28+DATA_FILES= odt-styles/reference.odt
2729
2830do-install:
2931 @${INSTALL_PROGRAM} ${WRKSRC}/dist/build/pandoc/pandoc ${PREFIX}/bin
32+.for f in ${DATA_FILES}
33+ @${INSTALL_DATA} ${WRKSRC}/${f} ${DATADIR}
34+.endfor
3035.for script in ${SCRIPTS}
3136 @${INSTALL_SCRIPT} ${WRKSRC}/${script} ${PREFIX}/bin
3237.endfor
macports/Portfile.in+7−2
@@ -40,13 +40,18 @@ destroot {
4040 ${destroot}${prefix}/libexec/${name}-${version}
4141 # install shell scripts:
4242 xinstall -m 755 -W ${worksrcpath} html2markdown hsmarkdown markdown2pdf \
43− ${destroot}${prefix}/bin
43+ markdown2odt ${destroot}${prefix}/bin
44+ # install data file:
45+ xinstall -d ${destroot}${prefix}/share/${name}
46+ xinstall -m 644 -W ${worksrcpath} odt-styles/reference.odt \
47+ ${destroot}${prefix}/share/${name}
4448 # install user documentation and man pages:
4549 xinstall -d ${destroot}${prefix}/share/doc/${name}
4650 xinstall -m 644 -W ${worksrcpath} README README.html COPYRIGHT BUGS \
4751 ${destroot}${prefix}/share/doc/${name}
4852 xinstall -m 644 -W ${worksrcpath}/man/man1 pandoc.1 hsmarkdown.1 \
49− markdown2pdf.1 html2markdown.1 ${destroot}${prefix}/share/man/man1
53+ markdown2pdf.1 html2markdown.1 markdown2odt.1 \
54+ ${destroot}${prefix}/share/man/man1
5055}
5156
5257post-activate {
man/man1/markdown2odt.1.mdnew file+52
@@ -0,0 +1,52 @@
1+% MARKDOWN2ODT(1) Pandoc User Manuals
2+% John MacFarlane and Recai Oktas
3+% March 14, 2008
4+
5+# NAME
6+
7+markdown2odt - converts markdown-formatted text to ODT
8+
9+# SYNOPSIS
10+
11+markdown2odt [*options*] [*input-file*]...
12+
13+# DESCRIPTION
14+
15+`markdown2odt` converts *input-file* (or text from standard
16+input) from markdown-formatted plain text to ODT (OpenDocument
17+Text) format. If no output filename is specified (using the `-o`
18+option), the name of the output file is derived from the input file;
19+thus, for example, if the input file is *hello.txt*, the output file
20+will be *hello.odt*. If the input is read from STDIN and no output
21+filename is specified, the output file will be named *stdin.odt*. If
22+multiple input files are specified, they will be concatenated before
23+conversion, and the name of the output file will be derived from the
24+first input file.
25+
26+Input is assumed to be in the UTF-8 character encoding. If your
27+local character encoding is not UTF-8, you should pipe input
28+through `iconv`:
29+
30+ iconv -t utf-8 input.txt | markdown2odt
31+
32+# OPTIONS
33+
34+`markdown2odt` is a wrapper around `pandoc`, so all of
35+`pandoc`'s options can be used with `markdown2odt` as well.
36+See `pandoc`(1) for a complete list.
37+The following options are most relevant:
38+
39+-o *FILE*, \--output=*FILE*
40+: Write output to *FILE*.
41+
42+\--strict
43+: Use strict markdown syntax, with no extensions or variants.
44+
45+-S, \--smart
46+: Use smart quotes, dashes, and ellipses. (This option is significant
47+ only when the input format is `markdown`. It is selected automatically
48+ when the output format is `latex` or `context`.)
49+
50+# SEE ALSO
51+
52+`pandoc`(1)
wrappers/markdown2odt.innew file+41
@@ -0,0 +1,41 @@
1+#!/bin/sh -e
2+
3+REQUIRED="zip"
4+SYNOPSIS="converts markdown-formatted text to ODT."
5+
6+### odtref.sh
7+
8+### common.sh
9+
10+### tempdir.sh
11+
12+if [ "$OUTPUT" = "-" ]; then
13+ firstinfile="$(echo $ARGS | sed -ne '1p')"
14+ firstinfilebase="${firstinfile%.*}"
15+ destname="${firstinfilebase:-stdin}.odt"
16+else
17+ destname="$OUTPUT"
18+fi
19+
20+(
21+ cp $REFERENCEODT $THIS_TEMPDIR/new.odt
22+ pandoc -s -r markdown -w opendocument "$@" -o $THIS_TEMPDIR/content.xml
23+ zip -9 -j $THIS_TEMPDIR/new.odt $THIS_TEMPDIR/content.xml
24+) || exit $?
25+
26+is_target_exists=
27+if [ -f "$destname" ]; then
28+ is_target_exists=1
29+ mv "$destname" "$destname~"
30+fi
31+
32+mv -f $THIS_TEMPDIR/new.odt "$destname"
33+
34+errn "Created $destname"
35+[ -z "$is_target_exists" ] || {
36+ errn " (previous file has been backed up as $destname~)"
37+}
38+
39+err .
40+
41+