diff options
author | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-11-13 16:34:07 +0000 |
---|---|---|
committer | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-11-13 16:34:07 +0000 |
commit | 19486ee0e17b12ed5a0c800c8cd8e43fe3522065 (patch) | |
tree | 5eaab59c602d3d0ac8abd1db09f967f1992cbf0b | |
parent | 5a66fa030d6ffd09d82b612f2b97bc737ec753a5 (diff) | |
download | pandoc-19486ee0e17b12ed5a0c800c8cd8e43fe3522065.tar.gz |
* Add PANDOC_OPTS support to 'markdown2pdf'.
* Sanitize comand line handling a bit in all wrappers:
+ Correct delimiters syntax should be ' -- '.
+ Print warning for extra arguments which are ignored.
+ Instead of positional arguments use named variables whenever
appropriate.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@97 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | html2markdown | 19 | ||||
-rw-r--r-- | latex2markdown | 8 | ||||
-rw-r--r-- | markdown2html | 8 | ||||
-rw-r--r-- | markdown2latex | 8 | ||||
-rw-r--r-- | markdown2pdf | 13 |
5 files changed, 38 insertions, 18 deletions
diff --git a/html2markdown b/html2markdown index 66370c3fa..bd248ca1f 100644 --- a/html2markdown +++ b/html2markdown @@ -23,14 +23,21 @@ for p in pandoc tidy; do done ALL="$*" -ARGS=${ALL%%-- *} -REST=${ALL#$ARGS} +ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant +set -- $ARGS -REST=${REST#--} +REST=${ALL#$ARGS}; REST=${REST#--} PANDOC_OPTS=${REST:-$PANDOC_OPTS} -if [ -z "$1" ] || [ -f $1 ]; then - tidy -utf8 $1 2>/dev/null | \ +infile=$1 +shift + +if [ -n "$@" ]; then + 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 @@ -55,7 +62,7 @@ else exit 1 ;; esac # Fetch and feed to pandoc. - $DUMPER $OPT $1 2>/dev/null | \ + $DUMPER $OPT $infile 2>/dev/null | \ tidy -utf8 2>/dev/null | \ pandoc $PANDOC_OPTS -r html -w markdown -s | \ iconv -f utf-8 diff --git a/latex2markdown b/latex2markdown index d6a991307..8f935aef5 100644 --- a/latex2markdown +++ b/latex2markdown @@ -22,11 +22,11 @@ for p in pandoc; do done ALL="$*" -ARGS=${ALL%%-- *} -REST=${ALL#$ARGS} +ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant +set -- $ARGS -REST=${REST#--} +REST=${ALL#$ARGS}; REST=${REST#--} PANDOC_OPTS=${REST:-$PANDOC_OPTS} -iconv -t utf-8 $ARGS | pandoc $PANDOC_OPTS -r latex -w markdown -s | \ +iconv -t utf-8 $* | pandoc $PANDOC_OPTS -r latex -w markdown -s | \ iconv -f utf-8 diff --git a/markdown2html b/markdown2html index 04ccf4c49..3c8647d77 100644 --- a/markdown2html +++ b/markdown2html @@ -22,10 +22,10 @@ for p in pandoc; do done ALL="$*" -ARGS=${ALL%%-- *} -REST=${ALL#$ARGS} +ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant +set -- $ARGS -REST=${REST#--} +REST=${ALL#$ARGS}; REST=${REST#--} PANDOC_OPTS=${REST:-$PANDOC_OPTS} -iconv -t utf-8 $ARGS | pandoc $PANDOC_OPTS | iconv -f utf-8 +iconv -t utf-8 $* | pandoc $PANDOC_OPTS | iconv -f utf-8 diff --git a/markdown2latex b/markdown2latex index 4f9e7d8f4..3e4d1da24 100644 --- a/markdown2latex +++ b/markdown2latex @@ -22,10 +22,10 @@ for p in pandoc; do done ALL="$*" -ARGS=${ALL%%-- *} -REST=${ALL#$ARGS} +ARGS=${ALL%% -- *} # only the part before ' -- ' delimiters is relevant +set -- $ARGS -REST=${REST#--} +REST=${ALL#$ARGS}; REST=${REST#--} PANDOC_OPTS=${REST:-$PANDOC_OPTS} -iconv -t utf-8 $ARGS | pandoc $PANDOC_OPTS -w latex -s | iconv -f utf-8 +iconv -t utf-8 $* | pandoc $PANDOC_OPTS -w latex -s | iconv -f utf-8 diff --git a/markdown2pdf b/markdown2pdf index 59c0ba634..80b2723cf 100644 --- a/markdown2pdf +++ b/markdown2pdf @@ -21,6 +21,13 @@ for p in pandoc pdflatex; do } 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 @@ -52,6 +59,12 @@ done } infile=$1 +shift + +if [ -n "$@" ]; then + echo >&2 "Warning: extra arguments '$@' will be ignored!" +fi + if [ -z "$outfile" ]; then if [ -n "$infile" ]; then outfile=${infile%.*}.pdf |