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
This commit is contained in:
parent
1cbcaa8802
commit
91d9fffe9e
5 changed files with 134 additions and 10 deletions
31
Makefile
31
Makefile
|
@ -11,6 +11,7 @@ BUILDDIR := dist
|
||||||
BUILDCONF := $(BUILDDIR)/setup-config
|
BUILDCONF := $(BUILDDIR)/setup-config
|
||||||
BUILDVARS := vars
|
BUILDVARS := vars
|
||||||
CONFIGURE := configure
|
CONFIGURE := configure
|
||||||
|
ODTSTYLES := odt-styles
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Cabal constants
|
# Cabal constants
|
||||||
|
@ -23,7 +24,7 @@ EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:\{0,1\}[[:space:]]*//p' $(CABAL))
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Install targets
|
# Install targets
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
WRAPPERS := html2markdown markdown2pdf hsmarkdown
|
WRAPPERS := html2markdown markdown2pdf hsmarkdown markdown2odt
|
||||||
# Add .exe extensions if we're running Windows/Cygwin.
|
# Add .exe extensions if we're running Windows/Cygwin.
|
||||||
EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
|
EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
|
||||||
sed -ne 's/^cygwin.*$$/\.exe/p')
|
sed -ne 's/^cygwin.*$$/\.exe/p')
|
||||||
|
@ -33,6 +34,7 @@ PROGS := $(EXECS) $(WRAPPERS)
|
||||||
MAIN := $(firstword $(EXECS))
|
MAIN := $(firstword $(EXECS))
|
||||||
DOCS := README.html README BUGS
|
DOCS := README.html README BUGS
|
||||||
MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
|
MANPAGES := $(patsubst %.md,%,$(wildcard $(MANDIR)/man?/*.?.md))
|
||||||
|
ODTREF := $(ODTSTYLES)/reference.odt
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Variables to setup through environment
|
# Variables to setup through environment
|
||||||
|
@ -106,10 +108,21 @@ awk ' \
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
endef
|
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
|
.PHONY: wrappers
|
||||||
wrappers: $(WRAPPERS)
|
wrappers: $(WRAPPERS)
|
||||||
cleanup_files+=$(WRAPPERS)
|
cleanup_files+=$(WRAPPERS)
|
||||||
$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
|
$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh $(ODTREFSH)
|
||||||
@$(generate-shell-script)
|
@$(generate-shell-script)
|
||||||
|
|
||||||
CABAL_BACKUP=$(CABAL).orig
|
CABAL_BACKUP=$(CABAL).orig
|
||||||
|
@ -179,7 +192,15 @@ install-doc: build-doc
|
||||||
uninstall-doc:
|
uninstall-doc:
|
||||||
-for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
|
-for f in $(DOCS); do rm -f $(PKGDOCPATH)/$$f; done
|
||||||
-for f in $(man_all); do rm -f $(MANPATH)/$$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.
|
# Program only installation.
|
||||||
.PHONY: install-exec uninstall-exec
|
.PHONY: install-exec uninstall-exec
|
||||||
|
@ -197,8 +218,8 @@ uninstall-exec:
|
||||||
|
|
||||||
# Program + user documents installation.
|
# Program + user documents installation.
|
||||||
.PHONY: install-program uninstall-program
|
.PHONY: install-program uninstall-program
|
||||||
install-program: install-exec install-doc
|
install-program: install-exec install-data install-doc
|
||||||
uninstall-program: uninstall-exec uninstall-doc
|
uninstall-program: uninstall-exec uninstall-doc uninstall-data
|
||||||
|
|
||||||
.PHONY: install-all uninstall-all
|
.PHONY: install-all uninstall-all
|
||||||
# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
|
# Full installation through Cabal: main + wrappers + user docs + lib + lib docs
|
||||||
|
|
|
@ -16,17 +16,22 @@ COMMENT= A general markup converter
|
||||||
BUILD_DEPENDS= ghc>=6.6:${PORTSDIR}/lang/ghc
|
BUILD_DEPENDS= ghc>=6.6:${PORTSDIR}/lang/ghc
|
||||||
|
|
||||||
MANCOMPRESSED= no
|
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_GMAKE= yes
|
||||||
USE_PERL5= 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
|
PORTDOCS= BUGS README README.html
|
||||||
SCRIPTS= hsmarkdown html2markdown markdown2pdf
|
SCRIPTS= hsmarkdown html2markdown markdown2pdf markdown2odt
|
||||||
|
DATA_FILES= odt-styles/reference.odt
|
||||||
|
|
||||||
do-install:
|
do-install:
|
||||||
@${INSTALL_PROGRAM} ${WRKSRC}/dist/build/pandoc/pandoc ${PREFIX}/bin
|
@${INSTALL_PROGRAM} ${WRKSRC}/dist/build/pandoc/pandoc ${PREFIX}/bin
|
||||||
|
.for f in ${DATA_FILES}
|
||||||
|
@${INSTALL_DATA} ${WRKSRC}/${f} ${DATADIR}
|
||||||
|
.endfor
|
||||||
.for script in ${SCRIPTS}
|
.for script in ${SCRIPTS}
|
||||||
@${INSTALL_SCRIPT} ${WRKSRC}/${script} ${PREFIX}/bin
|
@${INSTALL_SCRIPT} ${WRKSRC}/${script} ${PREFIX}/bin
|
||||||
.endfor
|
.endfor
|
||||||
|
|
|
@ -40,13 +40,18 @@ destroot {
|
||||||
${destroot}${prefix}/libexec/${name}-${version}
|
${destroot}${prefix}/libexec/${name}-${version}
|
||||||
# install shell scripts:
|
# install shell scripts:
|
||||||
xinstall -m 755 -W ${worksrcpath} html2markdown hsmarkdown markdown2pdf \
|
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:
|
# install user documentation and man pages:
|
||||||
xinstall -d ${destroot}${prefix}/share/doc/${name}
|
xinstall -d ${destroot}${prefix}/share/doc/${name}
|
||||||
xinstall -m 644 -W ${worksrcpath} README README.html COPYRIGHT BUGS \
|
xinstall -m 644 -W ${worksrcpath} README README.html COPYRIGHT BUGS \
|
||||||
${destroot}${prefix}/share/doc/${name}
|
${destroot}${prefix}/share/doc/${name}
|
||||||
xinstall -m 644 -W ${worksrcpath}/man/man1 pandoc.1 hsmarkdown.1 \
|
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 {
|
post-activate {
|
||||||
|
|
52
man/man1/markdown2odt.1.md
Normal file
52
man/man1/markdown2odt.1.md
Normal file
|
@ -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)
|
41
wrappers/markdown2odt.in
Normal file
41
wrappers/markdown2odt.in
Normal file
|
@ -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 .
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue