Merge changes in branches/wrappers into trunk.

[in trunk] svn merge -r105:HEAD \
        https://pandoc.googlecode.com/svn/branches/wrappers


git-svn-id: https://pandoc.googlecode.com/svn/trunk@177 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
roktas 2006-12-12 07:04:09 +00:00
parent 6411ea7466
commit 426cbadfef
25 changed files with 735 additions and 466 deletions

View file

@ -6,6 +6,7 @@
CABAL := Pandoc.cabal
SRCDIR := src
MANDIR := man
TESTDIR := tests
BUILDDIR := dist
BUILDCONF := .setup-config
BUILDCMD := runhaskell Setup.hs
@ -24,7 +25,8 @@ MAIN := $(firstword $(EXECS))
#-------------------------------------------------------------------------------
# Install targets
#-------------------------------------------------------------------------------
PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
WRAPPERS := html2markdown latex2markdown markdown2html markdown2latex markdown2pdf
PROGS := $(EXECS) $(WRAPPERS)
DOCS := README.html README BUGS TODO
#-------------------------------------------------------------------------------
@ -86,6 +88,27 @@ templates: $(SRCDIR)/templates
$(SRCDIR)/templates:
$(MAKE) -C $(SRCDIR)/templates
define generate-shell-script
echo "Generating $@..."; \
awk ' \
/^[ \t]*###+ / { \
lead = $$0; sub(/[^ \t].*$$/, "", lead); \
t = "$(dir $<)/"$$2; \
while (getline line < t > 0) \
print lead line; \
next; \
} \
{ print } \
' <$< >$@
endef
.PHONY: wrappers
wrappers: $(WRAPPERS)
wrapper_deps := $(wildcard $(SRCDIR)/wrappers/*.sh)
cleanup_files+=$(WRAPPERS)
%: $(SRCDIR)/wrappers/%.in $(wrapper_deps)
@$(generate-shell-script)
cleanup_files+=$(CABAL)
$(CABAL): cabalize $(CABAL).in
./cabalize <$(CABAL).in >$(CABAL)
@ -104,7 +127,7 @@ build: templates configure
$(BUILDCMD) build
.PHONY: build-exec
build-exec: $(EXECS)
build-exec: $(PROGS)
cleanup_files+=$(EXECS)
$(EXECS): build
for f in $@; do \
@ -250,11 +273,15 @@ osx-dmg: ../$(osx_dmg_name)
-rm -f $(osx_dmg_name)
mv $(osx_udzo_name) ../$(osx_dmg_name)
.PHONY: test test-markdown
.PHONY: test test-markdown test-wrapper
test: $(MAIN)
@cd tests && perl runtests.pl -s $(PWD)/$(MAIN)
@cd $(TESTDIR) && perl runtests.pl -s $(PWD)/$(MAIN)
test-markdown: $(MAIN)
@cd tests/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(MAIN) -tidy
@cd $(TESTDIR)/MarkdownTest_1.0.3 && perl MarkdownTest.pl -s $(PWD)/$(MAIN) -tidy
cleanup_files+=testwrapper
test-wrappers: testwrapper
@echo "Running $<..."
@sh testwrapper
# Stolen and slightly improved from a GPLed Makefile. Credits to John Meacham.
src_all:=$(shell find $(SRCDIR) -type f -name '*hs' | egrep -v '^\./(_darcs|lib|test)/')

168
README
View file

@ -39,24 +39,24 @@ STDIN. If you run it with file names as arguments, it will take input
from those files. It accepts several command-line options. For a
list, type
pandoc -h
pandoc -h
The most important options specify the format of the source file and
the output. The default reader is markdown; the default writer is
HTML. So if you don't specify a reader or writer, `pandoc` will
convert markdown to HTML. For example,
pandoc hello.txt
pandoc hello.txt
will convert `hello.txt` from markdown to HTML. For other conversions,
you must specify a reader and/or a writer using the `-r` and `-w`
flags. To convert markdown to LaTeX, you would write:
pandoc -w latex hello.txt
pandoc -w latex hello.txt
To convert html to markdown:
pandoc -r html -w markdown hello.txt
pandoc -r html -w markdown hello.txt
Supported writers include `markdown`, `latex`, `html`, `rtf` (rich text
format), `rst` (reStructuredText), and `s5` (which produces an HTML
@ -120,72 +120,74 @@ before the files can be found by TeX.)
# The shell scripts
For convenience, five shell scripts have been included that make it
easy to run `pandoc` without remembering all the command-line options.
All of the scripts use `iconv` to convert to and from the local
character encoding. All of the scripts presuppose that `pandoc`
is in the path, and some have additional requirements. (For example,
`html2markdown` uses `tidy`, and `markdown2pdf` uses `pdflatex`.)
Five shell scripts have been included that make it easy to run
`pandoc` without worrying about character encodings, and without
remembering all the command-line options:
1. `markdown2html` converts markdown to HTML. (This can be used
as a replacement for `Markdown.pl`.)
- `markdown2html` converts markdown-formatted text to HTML
- `markdown2latex` converts markdown-formatted text to LaTeX
- `markdown2pdf` produces a PDF file from markdown-formatted
text, using `pdflatex`.
- `html2markdown` converts HTML to markdown-formatted text
- `latex2markdown` converts LaTeX to markdown-formatted text
2. `html2markdown` can take either a filename or a URL as argument. If
it is given a URL, it uses `curl`, `wget`, or an available text-based
browser to fetch the contents of the specified URL, then filters this
through `tidy` to straighten up the HTML, and finally passes
this HTML to `pandoc` to produce markdown text:
All of the scripts use `iconv` (if available) to convert to and from
the local character encoding. All of the scripts presuppose that
`pandoc` is in the path, and some have additional requirements. (For
example, `html2markdown` uses `tidy`, and `markdown2pdf` uses
`pdflatex`.)
html2markdown http://www.fsf.org
When no arguments are specified, text will be read from standard
input. Arguments specify input files (limited to one in the case of
`latex2markdown` and `html2markdown`; the other scripts accept any number
of arguments). `html2markdown` may take a URL as argument instead of
a filename; in this case, `curl`, `wget`, or an available text-based
browser will be used to fetch the contents of the URL. (The `-n` option
inhibits this behavior; the `-g` option allows the user to specify a
custom command that will be used to fetch from a URL.)
html2markdown www.fsf.org
With the exception of `markdown2pdf`, the scripts write to standard output.
Output can be sent to a file using shell output redirection:
html2markdown subdir/mylocalfile.html
latex2markdown sample.tex > sample.txt
3. `latex2markdown` converts a LaTeX file to markdown:
The default behavior of `markdown2pdf` is to create a file with the same
base name as the first argument and the extension `pdf`; thus, for example,
latex2markdown mytexfile.tex
markdown2pdf sample.txt endnotes.txt
4. `markdown2latex` converts markdown to LaTeX:
will produce `sample.pdf`. (If `sample.pdf` exists already, it will be
backed up before being overwritten.) An output file name can be specified
explicitly using the `-o` option:
markdown2latex mytextfile.txt
markdown2pdf -o "My Book.pdf" chap1.txt chap2.txt chap3.txt
5. `markdown2pdf` converts markdown to PDF using `pdflatex`:
Options specific to the scripts, like `-o`, `-g`, and `-n`, must
be specified *before* any command-line arguments (file names or URLs).
Any options specified *after* the command-line arguments will be
passed directly to `pandoc`. For example,
markdown2pdf mytextfile.txt
markdown2html tusks.txt -S -T Elephants
creates a file `mytextfile.pdf`. To specify a different
name for the output file, use the `-o` option:
will convert `tusks.txt` to `tusks.html` using smart quotes, ellipses,
and dashes, with "Elephants" as the page title prefix. (For a
complete list of `pandoc` options, see below.) When there are no
command-line arguments (because input is from STDIN), `pandoc`
options must be preceded by ` -- `:
markdown2pdf -o final-draft.pdf mytextfile.txt
cat tusks.txt | markdown2html -- -S -T Elephants
If you want to use `pandoc`'s command-line options in these scripts,
put the options in the environment variable `PANDOC_OPTS`. For
example, to convert `tusks.txt` to `tusks.html` using smart quotes,
ellipses, and dashes, with "Elephants" as the page title prefix:
The ` -- ` separator may optionally be used when there are command-line
arguments:
PANDOC_OPTS="-S -T Elephants" markdown2html tusks.txt > tusks.html
To make these options persistent, use `export`:
export PANDOC_OPTS="-S -T Elephants"
markdown2html tusks.txt > tusks.html
markdown2html trunk.txt > trunk.html
You may also specify options on the command line, separating them
from the arguments with '` -- `':
markdown2html tusks.txt -- -S -T Elephants
Options specified in this way will override any options set in
`PANDOC_OPTS`.
markdown2html -- tusks.txt -S -T Elephants
# Command-line options
Various command-line options can be used to customize the output.
For a complete list, type
pandoc --help
pandoc --help
`-p` or `--preserve-tabs` causes tabs in the source text to be
preserved, rather than converted to spaces (the default).
@ -264,13 +266,13 @@ markdown test suite, type `make test-markdown`.)
Pandoc behaves differently from standard markdown on some "edge
cases" involving lists. Consider this source:
1. First
2. Second:
- Fee
- Fie
- Foe
1. First
2. Second:
- Fee
- Fie
- Foe
3. Third
3. Third
Pandoc transforms this into a "compact list" (with no `<p>` tags
around "First", "Second", or "Third"), while markdown puts `<p>`
@ -286,20 +288,20 @@ is followed by a blank line is irrelevant.
Standard markdown allows unescaped literal quotes in titles, as
in
[foo]: "bar "embedded" baz"
[foo]: "bar "embedded" baz"
Pandoc requires all quotes within titles to be escaped:
[foo]: "bar \"embedded\" baz"
[foo]: "bar \"embedded\" baz"
## Reference links
Pandoc allows implicit reference links in either of two styles:
1. Here's my [link]
2. Here's my [link][]
1. Here's my [link]
2. Here's my [link][]
[link]: linky.com
[link]: linky.com
If there's no corresponding reference, the implicit reference link
will appear as regular bracketed text. Note: even `[link][]` will
@ -313,18 +315,18 @@ Pandoc's markdown allows footnotes, using the following syntax:
here is a footnote reference,^(1) and another.^(longnote)
^(1) Here is the footnote. It can go anywhere in the document,
except in embedded contexts like block quotes or lists.
except in embedded contexts like block quotes or lists.
^(longnote) Here's the other note. This one contains multiple
blocks.
^
^ Caret characters are used to indicate that the blocks all belong
to a single footnote (as with block quotes).
to a single footnote (as with block quotes).
^
^ If you want, you can use a caret at the beginning of every line,
^ as with blockquotes, but all that you need is a caret at the
^ beginning of the first line of the block and any preceding
^ blank lines.
^ as with blockquotes, but all that you need is a caret at the
^ beginning of the first line of the block and any preceding
^ blank lines.
Footnote references may not contain spaces, tabs, or newlines.
@ -335,21 +337,21 @@ Markdown 1.0. While Markdown 1.0 leaves HTML blocks exactly as they
are, Pandoc treats text between HTML tags as markdown. Thus, for
example, Pandoc will turn
<table>
<tr>
<td>*one*</td>
<td>[a link](http://google.com)</td>
</tr>
</table>
<table>
<tr>
<td>*one*</td>
<td>[a link](http://google.com)</td>
</tr>
</table>
into
<table>
<tr>
<td><em>one</em></td>
<td><a href="http://google.com">a link</a></td>
</tr>
</table>
<table>
<tr>
<td><em>one</em></td>
<td><a href="http://google.com">a link</a></td>
</tr>
</table>
whereas Markdown 1.0 will preserve it as is.
@ -426,10 +428,10 @@ include BibTeX citations:
You can also use LaTeX environments. For example,
\begin{tabular}{|l|l|}\hline
Age & Frequency \\ \hline
Age & Frequency \\ \hline
18--25 & 15 \\
26--35 & 33 \\
36--45 & 22 \\ \hline
26--35 & 33 \\
36--45 & 22 \\ \hline
\end{tabular}
Note, however, that material between the begin and end tags will
@ -441,14 +443,14 @@ When run with the "standalone" option (`-s`), `pandoc` creates a
standalone file, complete with an appropriate header. To see the
default headers used for html and latex, use the following commands:
pandoc -D html
pandoc -D html
pandoc -D latex
pandoc -D latex
If you want to use a different header, just create a file containing
it and specify it on the command line as follows:
pandoc --header=MyHeaderFile
pandoc --header=MyHeaderFile
# Producing S5 with Pandoc

View file

@ -1,69 +0,0 @@
#!/bin/sh -e
# converts html to markdown
# uses an available program to fetch URL and tidy to normalize it first
pathfind () { # portable which(1), code taken from Debian Developer's Reference
OLDIFS="$IFS"
IFS=:
for _p in $PATH; do
if [ -x "$_p/$*" ]; then
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
for p in pandoc tidy; do
pathfind $p || {
echo >&2 "You need '$p' to use this program!"
exit 1
}
done
ALL="$*"
ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
set -- $ARGS
REST=${ALL#$ARGS}; REST=${REST# -- }
PANDOC_OPTS=${REST:-$PANDOC_OPTS}
infile=$1
if [ $# -gt 1 ]; then
shift
echo >&2 "Warning: extra arguments '$@' will be ignored!"
fi
if [ -z "$infile" ] || [ -f $infile ]; then
tidy -utf8 $infile 2>/dev/null | \
pandoc $PANDOC_OPTS -r html -w markdown -s | \
iconv -f utf-8
else
# Treat given argument as an URL. Locate a
# sensible text based browser (note the order).
for p in wget lynx w3m curl links w3c; do
if pathfind $p; then
DUMPER=$p
break
fi
done
# Setup proper options.
case "$DUMPER" in
wget) OPT="-O-" ;;
lynx) OPT="-source" ;;
w3m) OPT="-dump_source" ;;
curl) OPT="" ;;
links) OPT="-source" ;;
w3c) OPT="-n -get" ;;
"") printf "Needs a program to fetch the URL " >&2
printf "(e.g. wget, w3m, lynx, w3c, or curl)." >&2
exit 1 ;;
esac
# Fetch and feed to pandoc.
$DUMPER $OPT $infile 2>/dev/null | \
tidy -utf8 2>/dev/null | \
pandoc $PANDOC_OPTS -r html -w markdown -s | \
iconv -f utf-8
fi

View file

@ -1,32 +0,0 @@
#!/bin/sh -e
# runs pandoc to convert latex to markdown
pathfind () { # portable which(1), code taken from Debian Developer's Reference
OLDIFS="$IFS"
IFS=:
for _p in $PATH; do
if [ -x "$_p/$*" ]; then
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
for p in pandoc; do
pathfind $p || {
echo >&2 "You need '$p' to use this program!"
exit 1
}
done
ALL="$*"
ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
set -- $ARGS
REST=${ALL#$ARGS}; REST=${REST# -- }
PANDOC_OPTS=${REST:-$PANDOC_OPTS}
iconv -t utf-8 $* | pandoc $PANDOC_OPTS -r latex -w markdown -s | \
iconv -f utf-8

View file

@ -1,33 +1,60 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH HTML2MARKDOWN 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
html2markdown \- converts HTML to markdown-formatted text
.SH SYNOPSIS
\fBhtml2markdown\fR [ \fIinput-file\fR or \fIURL\fR ]
\fBhtml2markdown\fR [\fIoptions\fR] [\fIinput\-file\fR or \fIURL\fR]
[\fB\-\-\fR] [\fIpandoc\-opts\fR]
.SH DESCRIPTION
\fBhtml2markdown\fR converts \fIinput-file\fR or \fIURL\fR
(or text from STDIN) from HTML to markdown-formatted plain text.
It uses an available program (e.g. wget, w3m, lynx or curl) to fetch
the contents of the URL.
\fBhtml2markdown\fR converts \fIinput\-file\fR or \fIURL\fR (or text
from STDIN) from HTML to markdown\-formatted plain text.
If a URL is specified, \fBhtml2markdown\fR uses an available program
(e.g. wget, w3m, lynx or curl) to fetch its contents. Output is sent
to STDOUT.
.PP
\fBhtml2markdown\fR is a wrapper for \fBpandoc\fR.
.SH OPTIONS
.TP
.B \-\-
Any options appearing after ` \-\- ' on the command line will be passed
directly to \fBpandoc\fR. See \fBpandoc\fR(1) for a list of options
that may be used. Options specified in this way will override
PANDOC_OPTS (see below). Example:
.B \-h
Show usage message.
.TP
.B \-e \fIencoding\fR
Assume the character encoding \fIencoding\fR in reading the HTML.
(Note: \fIencoding\fR will be passed to \fBiconv\fR; a list of
available encodings may be obtained using `\fBiconv \-l\fR'.)
If the \fB\-e\fR option is not specified, the encoding will be
determined as follows: If input is from STDIN, the local encoding
will be assumed. Otherwise, \fBhtml2markdown\fR will try to
extract the character encoding from the "Content-type" meta tag.
If no character encoding is specified in this way, UTF-8 will be
assumed for a URL argument, and the local encoding will be assumed
for a file argument.
.TP
.B \-g \fIcommand\fR
Use \fIcommand\fR to fetch the contents of a URL. (By default,
\fBhtml2markdown\fR searches for an available program or text-based
browser to fetch the contents of a URL.) For example:
.IP
html2markdown input.txt -- -R
.SH ENVIRONMENT
Any command-line options contained in the PANDOC_OPTS environment variable
will be passed directly to \fBpandoc\fR. See \fBpandoc\fR(1)
for a list of options that may be used.
html2markdown \-g 'wget \-\-user=foo \-\-password=bar' mysite.com
.TP
.B \-n
Disable automatic fetching of contents when URLs are specified as
arguments.
.TP
.I pandoc\-opts
Any options appearing after \fIinput\-file\fR or \fIURL\fR on the
command line will be passed directly to \fBpandoc\fR. If no
\fIinput-file\fR or \fIURL\fR is specified, these options must
be preceded by ` \fB\-\-\fR '. (In other cases, ` \fB\-\-\fR ' is
optional.) See \fBpandoc\fR(1) for a list of options that may be used.
Example:
.IP
html2markdown input.txt \-\- \-R
.SH "SEE ALSO"
\fBpandoc\fR(1),
\fBmarkdown2html\fR(1),
\fBmarkdown2latex\fR(1),
\fBlatex2markdown\fR(1),
\fBmarkdown2pdf\fR(1)
\fBmarkdown2pdf\fR(1),
\fBiconv\fR(1)
.SH AUTHOR
John MacFarlane
John MacFarlane and Recai Oktas

View file

@ -1,26 +1,28 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH LATEX2MARKDOWN 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
latex2markdown \- converts LaTeX to markdown-formatted text
latex2markdown \- converts LaTeX to markdown\-formatted text
.SH SYNOPSIS
\fBlatex2markdown\fR [ \fIinput-file\fR ]
\fBlatex2markdown\fR [\fIoptions\fR] [\fIinput\-file\fR]
[\fB\-\-\fR] [\fIpandoc\-opts\fR]
.SH DESCRIPTION
\fBlatex2markdown\fR converts \fIinput-file\fR
(or text from STDIN) from LaTeX to markdown-formatted plain text.
\fBlatex2markdown\fR converts \fIinput\-file\fR
(or text from STDIN) from LaTeX to markdown\-formatted plain text.
Output is sent to STDOUT.
.PP
\fBlatex2markdown\fR is a wrapper for \fBpandoc\fR.
.SH OPTIONS
.TP
.B \-\-
Any options appearing after ` \-\- ' on the command line will be passed
directly to \fBpandoc\fR. See \fBpandoc\fR(1) for a list of options
that may be used. Options specified in this way will override
PANDOC_OPTS (see below). Example:
.B \-h
Show usage message.
.TP
.I pandoc\-opts
Any options appearing after \fIinput\-file\fR on the command line
will be passed directly to \fBpandoc\fR. If no \fIinput-file\fR
is specified, these options must be preceded by ` \fB\-\-\fR '.
(In other cases, ` \fB\-\-\fR ' is optional.) See \fBpandoc\fR(1)
for a list of options that may be used. Example:
.IP
latex2markdown input.txt -- -R
.SH ENVIRONMENT
Any command-line options contained in the PANDOC_OPTS environment variable
will be passed directly to \fBpandoc\fR. See \fBpandoc\fR(1)
for a list of options that may be used.
latex2markdown input.txt \-\- \-R
.SH "SEE ALSO"
\fBpandoc\fR(1),
\fBmarkdown2html\fR(1),
@ -28,4 +30,4 @@ for a list of options that may be used.
\fBmarkdown2latex\fR(1),
\fBmarkdown2pdf\fR(1)
.SH AUTHOR
John MacFarlane
John MacFarlane and Recai Oktas

View file

@ -1,28 +1,29 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH MARKDOWN2HTML 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
markdown2html \- converts markdown-formatted text to HTML
markdown2html \- converts markdown\-formatted text to HTML
.SH SYNOPSIS
\fBmarkdown2html\fR [ \fIinput-files\fR ]
\fBmarkdown2html\fR [\fIoptions\fR] [\fIinput\-file\fR]...
[\fB\-\-\fR] [\fIpandoc\-opts\fR]
.SH DESCRIPTION
\fBmarkdown2html\fR converts \fIinput-files\fR
(or text from STDIN) from markdown-formatted plain text to HTML.
\fBmarkdown2html\fR converts \fIinput\-file\fR
(or text from STDIN) from markdown\-formatted plain text to HTML.
If multiple files are specified, they will be combined to make a single
HTML document.
HTML document. Output is sent to STDOUT.
.PP
\fBmarkdown2html\fR is a wrapper for \fBpandoc\fR.
.SH OPTIONS
.TP
.B \-\-
Any options appearing after ` \-\- ' on the command line will be passed
directly to \fBpandoc\fR. See \fBpandoc\fR(1) for a list of options
that may be used. Options specified in this way will override
PANDOC_OPTS (see below). Example:
.B \-h
Show usage message.
.TP
.I pandoc\-opts
Any options appearing after \fIinput\-file\fR... on the command line
will be passed directly to \fBpandoc\fR. If no \fIinput-file\fR
is specified, these options must be preceded by ` \fB\-\-\fR '.
(In other cases, ` \fB\-\-\fR ' is optional.) See \fBpandoc\fR(1)
for a list of options that may be used. Example:
.IP
markdown2html input.txt -- --css=main.css -S
.SH ENVIRONMENT
Any command-line options contained in the PANDOC_OPTS environment variable
will be passed directly to \fBpandoc\fR. See \fBpandoc\fR(1)
for a list of options that may be used.
markdown2html input.txt \-\- \-\-css=main.css \-S
.SH "SEE ALSO"
\fBpandoc\fR(1),
\fBhtml2markdown\fR(1),
@ -30,4 +31,4 @@ for a list of options that may be used.
\fBlatex2markdown\fR(1),
\fBmarkdown2pdf\fR(1)
.SH AUTHOR
John MacFarlane
John MacFarlane and Recai Oktas

View file

@ -1,27 +1,29 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH MARKDOWN2LATEX 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
markdown2latex \- converts markdown-formatted text to LaTeX
.SH SYNOPSIS
\fBmarkdown2latex\fR [ \fIinput-files\fR ]
\fBmarkdown2latex\fR [\fIoptions\fR] [\fIinput\-file\fR]...
[\fB\-\-\fR] [\fIpandoc\-opts\fR]
.SH DESCRIPTION
\fBmarkdown2latex\fR converts \fIinput-files\fR (or text from STDIN)
from markdown-formatted plain text to LaTeX. If multiple files are
\fBmarkdown2latex\fR converts \fIinput\-file\fR (or text from STDIN)
from markdown\-formatted plain text to LaTeX. If multiple files are
specified, they will be combined to make a single LaTeX document.
Output is sent to STDOUT.
.PP
\fBmarkdown2latex\fR is a wrapper for \fBpandoc\fR.
.SH OPTIONS
.TP
.B \-\-
Any options appearing after ` \-\- ' on the command line will be passed
directly to \fBpandoc\fR. See \fBpandoc\fR(1) for a list of options
that may be used. Options specified in this way will override
PANDOC_OPTS (see below). Example:
.B \-h
Show usage message.
.TP
.I pandoc\-opts
Any options appearing after \fIinput\-file\fR... on the command line
will be passed directly to \fBpandoc\fR. If no \fIinput-file\fR
is specified, these options must be preceded by ` \fB\-\-\fR '.
(In other cases, ` \fB\-\-\fR ' is optional.) See \fBpandoc\fR(1)
for a list of options that may be used. Example:
.IP
markdown2latex input.txt -- --custom-header=letterhead.tex
.SH ENVIRONMENT
Any command-line options contained in the PANDOC_OPTS environment variable
will be passed directly to \fBpandoc\fR. See \fBpandoc\fR(1)
for a list of options that may be used.
markdown2latex input.txt \-\- \-\-custom\-header=letterhead.tex
.SH "SEE ALSO"
\fBpandoc\fR(1),
\fBmarkdown2html\fR(1),
@ -29,4 +31,4 @@ for a list of options that may be used.
\fBlatex2markdown\fR(1),
\fBmarkdown2pdf\fR(1)
.SH AUTHOR
John MacFarlane
John MacFarlane and Recai Oktas

View file

@ -1,38 +1,37 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH MARKDOWN2PDF 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
markdown2pdf \- converts markdown-formatted text to PDF, using pdflatex
.SH SYNOPSIS
\fBmarkdown2pdf\fR [ \fB-o|--output\fR \fIoutput-file\fR ]
[ \fIinput-file\fR ]
\fBmarkdown2pdf\fR [\fIoptions\fR] [\fB\-o\fR \fIoutput-file\fR]
[\fIinput-file\fR]... [\fB\-\-\fR] [\fIpandoc\-opts\fR]
.SH DESCRIPTION
\fBmarkdown2pdf\fR converts \fIinput-file\fR (or text from STDIN) from
markdown-formatted plain text to PDF, using \fBpdflatex\fR. If no output
\fBmarkdown2pdf\fR converts \fIinput\-file\fR (or text from STDIN) from
markdown\-formatted plain text to PDF, using \fBpdflatex\fR. If no output
filename is specified, the name of the output file is derived from the
input file; thus, for example, if the input file is \fIhello.txt\fR,
the output file will be \fIhello.pdf\fR. If the input is read from STDIN
and no output filename is specified, the output file will be named
\fIstdin.pdf\fR.
\fIstdin.pdf\fR. 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.
.PP
\fBmarkdown2pdf\fR is a wrapper for \fBpandoc\fR.
.SH OPTIONS
.TP
.B \-o FILENAME, \-\-output=FILENAME
Specify name of output (PDF) file.
.TP
.B \-h, \-\-help
.B \-h
Show usage message.
.TP
.B \-\-
Any options appearing after ` \-\- ' on the command line will be passed
directly to \fBpandoc\fR. See \fBpandoc\fR(1) for a list of options
that may be used. Options specified in this way will override
PANDOC_OPTS (see below). Example:
.B \-o \fIoutput-file\fR
Specify name of output (PDF) file.
.TP
.I pandoc\-opts
Any options appearing after \fIinput\-file\fR... on the command line
will be passed directly to \fBpandoc\fR. If no \fIinput-file\fR
is specified, these options must be preceded by ` \fB\-\-\fR '.
(In other cases, ` \fB\-\-\fR ' is optional.) See \fBpandoc\fR(1)
for a list of options that may be used. Example:
.IP
markdown2pdf input.txt -- --custom-header=letterhead.tex
.SH ENVIRONMENT
Any command-line options contained in the PANDOC_OPTS environment variable
will be passed directly to \fBpandoc\fR. See \fBpandoc\fR(1)
for a list of options that may be used.
markdown2pdf input.txt \-\- \-\-custom\-header=letterhead.tex
.SH "SEE ALSO"
\fBpandoc\fR(1),
\fBmarkdown2html\fR(1),
@ -41,4 +40,4 @@ for a list of options that may be used.
\fBlatex2markdown\fR(1),
\fBpdflatex\fR(1)
.SH AUTHOR
John MacFarlane
John MacFarlane and Recai Oktas

View file

@ -1,36 +1,35 @@
.TH PANDOC 1 "November 1, 2006" Linux "User Manuals"
.TH PANDOC 1 "November 21, 2006" Pandoc "User Manuals"
.SH NAME
pandoc \- general markup converter
.SH SYNOPSIS
\fBpandoc\fR [ \fIoptions\fR ] [ \fIinput-files\fR ]
\fBpandoc\fR [\fIoptions\fR] [\fIinput\-file\fR]...
.SH DESCRIPTION
\fIPandoc\fR converts files from one markup format to another. It can
read markdown and (subsets of) reStructuredText, HTML, and LaTeX, and
it can write markdown, reStructuredText, HTML, LaTeX, RTF, and S5 HTML
slide shows.
.PP
If no \fIinput-files\fR are specified, input is read from STDIN. Otherwise,
the \fIinput-files\fR are concatenated (with a blank line between each)
If no \fIinput\-file\fR is specified, input is read from STDIN. Otherwise,
the \fIinput\-files\fR are concatenated (with a blank line between each)
and used as input. Output goes to STDOUT. If you want output to a file,
use shell redirection:
.IP
.B pandoc input.txt > output.html
.PP
The default behavior of \fIPandoc\fR is to convert the input from
markdown-formatted plain text to HTML. Different input and output
formats can be specified using command-line options. For example,
markdown\-formatted plain text to HTML. Different input and output
formats can be specified using command\-line options. For example,
.IP
.B pandoc -f latex -t markdown chap1.tex > chap1.txt
.B pandoc \-f latex \-t markdown chap1.tex > chap1.txt
.PP
converts \fIchap1.tex\fR from LaTeX to markdown-formatted plain text.
See below for a detailed list of command-line options.
converts \fIchap1.tex\fR from LaTeX to markdown\-formatted plain text.
See below for a detailed list of command\-line options.
.PP
\fIPandoc\fR uses the UTF-8 character encoding for both input and output.
If your local character encoding is not UTF-8, you should pipe input
\fIPandoc\fR uses the UTF\-8 character encoding for both input and output.
If your local character encoding is not UTF\-8, you should pipe input
and output through \fBiconv\fR:
.IP
.B iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
.B iconv \-t utf\-8 input.txt | pandoc | iconv \-f utf\-8
.SH OPTIONS
.TP
@ -40,7 +39,7 @@ Print version.
.B \-h, \-\-help
Show usage message.
.TP
.B \-f FORMAT, \-r FORMAT, --from=FORMAT, --read=FORMAT
.B \-f FORMAT, \-r FORMAT, \-\-from=FORMAT, \-\-read=FORMAT
Specify input format.
.I FORMAT
can be
@ -56,7 +55,7 @@ or
.I latex
(LaTeX).
.TP
.B \-t FORMAT, \-w FORMAT, --to=FORMAT, --write=FORMAT
.B \-t FORMAT, \-w FORMAT, \-\-to=FORMAT, \-\-write=FORMAT
Specify output format.
.I FORMAT
can be

View file

@ -1,31 +0,0 @@
#!/bin/sh -e
# converts markdown to HTML
pathfind () { # portable which(1), code taken from Debian Developer's Reference
OLDIFS="$IFS"
IFS=:
for _p in $PATH; do
if [ -x "$_p/$*" ]; then
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
for p in pandoc; do
pathfind $p || {
echo >&2 "You need '$p' to use this program!"
exit 1
}
done
ALL="$*"
ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
set -- $ARGS
REST=${ALL#$ARGS}; REST=${REST# -- }
PANDOC_OPTS=${REST:-$PANDOC_OPTS}
iconv -t utf-8 $* | pandoc $PANDOC_OPTS | iconv -f utf-8

View file

@ -1,31 +0,0 @@
#!/bin/sh -e
# converts markdown to latex
pathfind () { # portable which(1), code taken from Debian Developer's Reference
OLDIFS="$IFS"
IFS=:
for _p in $PATH; do
if [ -x "$_p/$*" ]; then
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
for p in pandoc; do
pathfind $p || {
echo >&2 "You need '$p' to use this program!"
exit 1
}
done
ALL="$*"
ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
set -- $ARGS
REST=${ALL#$ARGS}; REST=${REST# -- }
PANDOC_OPTS=${REST:-$PANDOC_OPTS}
iconv -t utf-8 $* | pandoc $PANDOC_OPTS -w latex -s | iconv -f utf-8

View file

@ -1,113 +0,0 @@
#!/bin/sh
# converts markdown to latex, then uses latex to make a PDF
pathfind () { # portable which(1), code taken from Debian Developer's Reference
OLDIFS="$IFS"
IFS=:
for _p in $PATH; do
if [ -x "$_p/$*" ]; then
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
for p in pandoc pdflatex; do
pathfind $p || {
echo >&2 "You need '$p' to use this program!"
exit 1
}
done
ALL="$*"
ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant
set -- $ARGS
REST=${ALL#$ARGS}; REST=${REST# -- }
PANDOC_OPTS=${REST:-$PANDOC_OPTS}
outfile=
for option; do
if [ -n "$prev" ]; then
eval "$prev=\$option"
prev=
shift
continue
fi
optarg=$(expr "x$option" : 'x[^=]*=\(.*\)')
case $option in
-h | --h | --help )
help=1
shift ;;
-o | --o | --output )
prev=outfile
shift ;;
-o=* | --o=* | --output=* )
outfile=$optarg
shift ;;
-* ) echo >&2 "$0: unknown option: $option; aborting"
exit 1 ;;
* ) break ;;
esac
done
[ -z "$help" ] || {
echo >&2 "Usage: $0 [-o|--output output-file] [input-file]"
exit 0
}
infile=$1
if ! [ -r $infile ]; then
echo >&2 "'$infile' not found"
exit 1
fi
if [ $# -gt 1 ]; then
shift
echo >&2 "Warning: extra arguments '$@' will be ignored!"
fi
if [ -z "$outfile" ]; then
if [ -n "$infile" ]; then
outfile=${infile%.*}.pdf
else
outfile='stdin.pdf' # input is STDIN, since no argument given
fi
fi
BASE=${outfile##*/}
BASE=${BASE%.*}
set -e
TEMP=${TMPDIR-/tmp}/markdown2pdf.$$
trap "status=$?; rm -rf $TEMP; exit $status" 0 INT
mkdir -p $TEMP
iconv -t utf-8 $infile | \
pandoc $PANDOC_OPTS -w latex -s | \
iconv -f utf-8 > $TEMP/$BASE.tex && (
cd $TEMP
if ! pdflatex -interaction=batchmode $BASE.tex >/dev/null 2>&1; then
echo >&2 "LaTeX errors:"
sed -ne '/^!/,/^ *$/p' $BASE.log >&2
exit 1
fi
) || exit $?
is_target_exists=
if [ -f $outfile ]; then
is_target_exists=1
mv -f $outfile $outfile~
fi
mv -f $TEMP/$BASE.pdf $outfile
printf "Created $outfile" >&2
[ -z "$is_target_exists" ] || {
printf " (previous file has been backed up as '$outfile~')" >&2
}
echo >&2 .

7
src/wrappers/checkin.sh Normal file
View file

@ -0,0 +1,7 @@
# Check if input files exist.
for f; do
if [ -n "$f" ] && ! [ -f "$f" ]; then
err "File '$f' not found."
exit 1
fi
done

56
src/wrappers/common.sh Normal file
View file

@ -0,0 +1,56 @@
THIS=${0##*/}
NEWLINE='
'
WRAPPER_ARGS=
WRAPPEE_ARGS=
err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
usage () {
synopsis="$@"
err "Usage: $THIS $synopsis"
err "See $THIS(1) man file for details."
}
runpandoc () {
if [ -n "$WRAPPEE_ARGS" ]; then
# Unpack arguments that will be passed to pandoc.
oldifs="$IFS"; IFS="$NEWLINE"; set -- $WRAPPEE_ARGS "$@"; IFS="$oldifs"
case "$1" in --) shift;; esac # tolerate the existence of a leading '--'
fi
pandoc "$@"
}
# Portable which(1).
pathfind () {
oldifs="$IFS"; IFS=':'
for _p in $PATH; do
if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
IFS="$oldifs"
return 0
fi
done
IFS="$oldifs"
return 1
}
HAVE_ICONV=
if pathfind iconv; then
HAVE_ICONV=1
alias to_utf8='iconv -t utf-8'
alias from_utf8='iconv -f utf-8'
else
err "Warning: iconv not present. Assuming UTF-8 character encoding."
alias to_utf8='cat'
alias from_utf8='cat'
fi
for p in pandoc $REQUIRED; do
pathfind $p || {
err "You need '$p' to use this program!"
exit 1
}
done

12
src/wrappers/getopts.sh Normal file
View file

@ -0,0 +1,12 @@
if [ -z "$SYNOPSIS" ]; then
SYNOPSIS="[-h] [input_file]"
[ -n "$THIS_NARG" ] || SYNOPSIS="${SYNOPSIS}..."
fi
while getopts h opt; do
case $opt in
h|?) usage "$SYNOPSIS"; exit 2 ;;
esac
done
shift $(($OPTIND - 1))

View file

@ -0,0 +1,134 @@
#!/bin/sh -e
# converts html to markdown
# uses an available program to fetch URL and tidy to normalize it first
REQUIRED=tidy
### common.sh
grab_url_with () {
url="${1:?internal error: grab_url_with: url required}"
shift
cmdline="$@"
prog=
prog_opts=
if [ -n "$cmdline" ]; then
eval "set -- $cmdline"
prog=$1
shift
prog_opts="$@"
fi
if [ -z "$prog" ]; then
# Locate a sensible web grabber (note the order).
for p in wget lynx w3m curl links w3c; do
if pathfind $p; then
prog=$p
break
fi
done
[ -n "$prog" ] || {
errn "$THIS: Couldn't find a program to fetch the file from URL "
err "(e.g. wget, w3m, lynx, w3c, or curl)."
return 1
}
else
pathfind "$prog" || {
err "$THIS: No such web grabber '$prog' found; aborting."
return 1
}
fi
# Setup proper base options for known grabbers.
base_opts=
case "$prog" in
wget) base_opts="-O-" ;;
lynx) base_opts="-source" ;;
w3m) base_opts="-dump_source" ;;
curl) base_opts="" ;;
links) base_opts="-source" ;;
w3c) base_opts="-n -get" ;;
*) err "$THIS: unhandled web grabber '$prog'; hope it succeeds."
esac
err "$THIS: invoking '$prog $base_opts $prog_opts $url'..."
eval "set -- $base_opts $prog_opts"
$prog "$@" "$url"
}
encoding=
grabber=
nograb=
while getopts e:g:nh opt; do
case $opt in
e) encoding="$OPTARG" ;;
g) grabber="$OPTARG" ;;
n) nograb=1 ;;
h|?)
usage "[-e encoding] [-g grabber_command] [-n] [-h] [input_file|url]"
exit 2 ;;
esac
done
shift $(($OPTIND - 1))
### postopts.sh
### singlearg.sh
inurl=
if [ -n "$1" ] && ! [ -f "$1" ]; then
if [ -n "$nograb" ]; then
err "'$1' not found; refusing to treat input as URL."
exit 1
fi
# Treat given argument as an URL.
inurl="$1"
fi
if [ -n "$inurl" ]; then
err "Attempting to fetch file from '$inurl'..."
### tempdir.sh
grabber_out=$THIS_TEMPDIR/grabber.out
grabber_log=$THIS_TEMPDIR/grabber.log
if ! grab_url_with "$inurl" "$grabber" 1>$grabber_out \
2>$grabber_log; then
errn "grab_url_with failed"
if [ -f $grabber_log ]; then
err " with the following error log."
err
cat >&2 $grabber_log
else
err .
fi
exit 1
fi
set -- $grabber_out
fi
if [ -z "$encoding" ] && [ "x$@" != "x" ]; then
# Try to determine character encoding unless not specified
# and input is STDIN.
encoding=$(
head "$@" |
LC_ALL=C tr 'A-Z' 'a-z' |
sed -ne '/<meta .*content-type.*charset=/ {
s/.*charset=["'\'']*\([-a-zA-Z0-9]*\).*["'\'']*/\1/p
}'
)
fi
if [ -n "$encoding" ] && [ -n "$HAVE_ICONV" ]; then
alias to_utf8='iconv -f "$encoding" -t utf-8'
elif [ -n "$inurl" ]; then # assume web pages are UTF-8
alias to_utf8='cat'
fi # else just use local encoding
to_utf8 "$@" | tidy -utf8 2>/dev/null |
runpandoc -r html -w markdown -s | from_utf8

View file

@ -0,0 +1,14 @@
#!/bin/sh -e
# runs pandoc to convert latex to markdown
### common.sh
### getopts.sh
### postopts.sh
### singlearg.sh
### checkin.sh
to_utf8 "$@" | runpandoc -r latex -w markdown -s | from_utf8

View file

@ -0,0 +1,12 @@
#!/bin/sh -e
# converts markdown to HTML
### common.sh
### getopts.sh
### postopts.sh
### checkin.sh
to_utf8 "$@" | runpandoc | from_utf8

View file

@ -0,0 +1,12 @@
#!/bin/sh -e
# converts markdown to latex
### common.sh
### getopts.sh
### postopts.sh
### checkin.sh
to_utf8 "$@" | runpandoc -w latex -s | from_utf8

View file

@ -0,0 +1,64 @@
#!/bin/sh -e
# converts markdown to latex, then uses latex to make a PDF
REQUIRED=pdflatex
### common.sh
outfile=
while getopts o:h opt; do
case $opt in
o) outfile="$OPTARG" ;;
h|?) usage "[-o output_file] [-h] [input_file]..."; exit 2 ;;
esac
done
shift $(($OPTIND - 1))
### postopts.sh
### checkin.sh
if [ -z "$outfile" ]; then
if [ -n "$1" ]; then
outfile="${1%.*}"
else
outfile="stdin" # input is STDIN, since no argument given
fi
fi
case "$outfile" in
*.*) ;; # skip appending extension if one is already present
*) outfile="${outfile%.*}.pdf";;
esac
### tempdir.sh
# We should use a filename without white spaces for pdflatex.
TEXNAME=$THIS
to_utf8 "$@" | runpandoc -w latex -s >$THIS_TEMPDIR/$TEXNAME.tex
(
cd $THIS_TEMPDIR
if ! pdflatex -interaction=batchmode $TEXNAME.tex >/dev/null 2>&1; then
err "LaTeX errors:"
from_utf8 $TEXNAME.log | sed -ne '/^!/,/^ *$/p' >&2
if grep -q "File \`ucs.sty' not found" $TEXNAME.log; then
err "Please install the 'unicode' package from ctan.org."
fi
exit 1
fi
)
is_target_exists=
if [ -f "$outfile" ]; then
is_target_exists=1
mv -f "$outfile" "$outfile~"
fi
mv -f $THIS_TEMPDIR/$TEXNAME.pdf "$outfile"
errn "Created '$outfile'"
[ -z "$is_target_exists" ] || {
errn " (previous file has been backed up as '$outfile~')"
}
err .

17
src/wrappers/postopts.sh Normal file
View file

@ -0,0 +1,17 @@
# Parse wrapper and wrappee (pandoc) arguments by taking
# into account that they may have space or tab characters.
pick="WRAPPER_ARGS"
while [ $# -gt 0 ]; do
if [ "$pick" = "WRAPPER_ARGS" ]; then
case "$1" in
-*) pick="WRAPPEE_ARGS" ;;
esac
fi
# Pack args with NEWLINE to preserve spaces,
# and put them into the picked variable.
eval "$pick=\"\$${pick}${NEWLINE}${1}\""
shift
done
# Unpack filename arguments. Now "$@" will hold the filenames.
oldifs="$IFS"; IFS="$NEWLINE"; set -- $WRAPPER_ARGS; IFS="$oldifs"

View file

@ -0,0 +1,7 @@
# Ensure to work with a single argument.
if [ $# -gt 1 ]; then
first_arg="$1"
shift
err "Warning: extra arguments '$@' will be ignored."
set -- $first_arg
fi

10
src/wrappers/tempdir.sh Normal file
View file

@ -0,0 +1,10 @@
# As a security measure refuse to proceed if mktemp is not available.
pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
THIS_TEMPDIR=
THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
readonly THIS_TEMPDIR
trap 'exitcode=$?
[ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
exit $exitcode' 0 1 2 3 13 15

141
src/wrappers/testwrapper.in Normal file
View file

@ -0,0 +1,141 @@
#!/bin/sh
THIS=$1
ASH="ash -s"
BASH="bash --posix -s"
DASH="dash -s"
KSH="ksh -s"
POSH="posh -s"
ZSH="zsh -s"
ERROR=""
wrapper () {
$SH -- "$@" <<-'EOF'
### common.sh
outfile=
while getopts o: opt; do
case $opt in
o) outfile="$OPTARG" ;;
esac
done
shift $(($OPTIND - 1))
### postopts.sh
echo "Options passed to wrapper:"
[ -z "$outfile" ] || echo "|$outfile|"
echo "Arguments passed to wrapper:"
for arg; do
echo "|$arg|"
done
pandoc () {
echo "Arguments passed to wrappee:"
for arg; do
echo "|$arg|"
done
}
runpandoc
EOF
}
# Portable which(1).
pathfind () {
oldifs="$IFS"; IFS=':'
for _p in $PATH; do
if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
IFS="$oldifs"
return 0
fi
done
IFS="$oldifs"
return 1
}
check_results () {
if [ "$1" = "$2" ]; then
echo >&2 ok
return 0
else
echo >&2 failed
sed "s/^/\t/" >&2 <<EOF
Command line: '$3'
===> Expected:
$2
<=== Got:
$1
EOF
return 1
fi
}
for SH in "$BASH" "$DASH" "$KSH" "$ZSH"; do
CMD=${SH%% *}
echo >&2 " Testing with $CMD..."
if pathfind "$CMD"; then
if [ "$CMD" = "zsh" ]; then
# Zsh needs to be called as 'sh' to enable POSIX mode.
ln -s $(which zsh) ./sh
SH="./sh ${SH#* }"
trap 'err=$?; rm -f ./sh; exit $err' 0 1 2 3 13 15
fi
set -e
# Test 1
printf >&2 " test case 1... "
actual=$(wrapper -o "output file" "foo bar" -A "quux baz" -B)
expected=$(cat <<'EOF'
Options passed to wrapper:
|output file|
Arguments passed to wrapper:
|foo bar|
Arguments passed to wrappee:
|-A|
|quux baz|
|-B|
EOF
)
check_results "$actual" "$expected" \
'wrapper -o "output file" "foo bar" -A "quux baz" -B'
# Test 2
printf >&2 " test case 2... "
actual=$(wrapper -- -A "foo bar")
expected=$(cat <<'EOF'
Options passed to wrapper:
Arguments passed to wrapper:
Arguments passed to wrappee:
|-A|
|foo bar|
EOF
)
check_results "$actual" "$expected" 'wrapper -- -A "foo bar"'
# Test 3 (Test 1 with a redundant '--')
printf >&2 " test case 4... "
actual=$(wrapper -o "output file" "foo bar" -- -A "quux baz" -B)
expected=$(cat <<'EOF'
Options passed to wrapper:
|output file|
Arguments passed to wrapper:
|foo bar|
Arguments passed to wrappee:
|-A|
|quux baz|
|-B|
EOF
)
check_results "$actual" "$expected" \
'wrapper -o "output file" "foo bar" -- -A "quux baz" -B'
else
echo >&2 "Warning: cannot verify correctness with $CMD; shell not available"
fi
done
exit 0