git.iko.soy/typeable/pandoc
on master help sign in
Include shell scripts themselves in repo, rather than generating from wrappers.

+ Removed wrappers directory + Removed wrappers Makefile target + Added hsmarkdown, html2markdown, and markdown2pdf git-svn-id: https://pandoc.googlecode.com/svn/trunk@1387 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2ba5ff94833c9fee0fb2799e5440d8b235f9410e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 9 Aug 2008, 23:45 (18 years ago) parentdb729a0
7 files changed+122−89
.gitignore−3 Makefile−21 wrappers/hsmarkdown.in → hsmarkdown wrappers/html2markdown.in → html2markdown+61−2 wrappers/markdown2pdf.in → markdown2pdf+61−2 wrappers/common.sh−43 wrappers/tempdir.sh−18
.gitignore−3
@@ -5,9 +5,6 @@ INSTALL.*
55.configure-stamp
66man/man?/*.1
77man/man?/*.html
8−markdown2pdf
9−html2markdown
10−hsmarkdown
118*.diff
129pandoc.cabal.orig
1310
Makefile−21
@@ -93,33 +93,12 @@ all: build-program
9393%.1: %.1.md $(MAIN)
9494 ./$(MAIN) -s -S -w man $< >$@ || rm -f $@
9595
96−define generate-shell-script
97−echo >&2 "Generating $@..."; \
98−awk ' \
99− /^[ \t]*###+ / { \
100− lead = $$0; sub(/[^ \t].*$$/, "", lead); \
101− t = "$(dir $<)/"$$2; \
102− while (getline line < t > 0) \
103− print lead line; \
104− next; \
105− } \
106− { print } \
107−' <$< >$@
108−chmod +x $@
109−endef
110−
11196cleanup_files+=$(ODTREF)
11297$(ODTREF): $(addprefix $(ODTSTYLES)/, layout-cache meta.xml styles.xml content.xml mimetype \
11398 settings.xml Configurations2 Thumbnails META-INF)
11499 cd $(ODTSTYLES) ; \
115100 zip -9 -q -r $(notdir $@) * -x $(notdir $@)
116101
117−.PHONY: wrappers
118−wrappers: $(WRAPPERS)
119−cleanup_files+=$(WRAPPERS)
120−$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
121− @$(generate-shell-script)
122−
123102.PHONY: configure
124103cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
125104ifdef GHC_PKG
wrappers/hsmarkdown.in → hsmarkdownrenamed

Only the mode changed.

wrappers/html2markdown.in → html2markdownrenamed+61−2
@@ -5,7 +5,49 @@
55REQUIRED="tidy"
66SYNOPSIS="converts HTML from a URL, file, or STDIN to markdown-formatted text."
77
8−### common.sh
8+THIS=${0##*/}
9+
10+NEWLINE='
11+'
12+
13+err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
14+errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
15+
16+usage () {
17+ err "$1 - $2" # short description
18+ err "See the $1(1) man page for usage."
19+}
20+
21+# Portable which(1).
22+pathfind () {
23+ oldifs="$IFS"; IFS=':'
24+ for _p in $PATH; do
25+ if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
26+ IFS="$oldifs"
27+ return 0
28+ fi
29+ done
30+ IFS="$oldifs"
31+ return 1
32+}
33+
34+for p in pandoc $REQUIRED; do
35+ pathfind $p || {
36+ err "You need '$p' to use this program!"
37+ exit 1
38+ }
39+done
40+
41+CONF=$(pandoc --dump-args "$@" 2>&1) || {
42+ errcode=$?
43+ echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
44+ [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
45+ exit $errcode
46+}
47+
48+OUTPUT=$(echo "$CONF" | sed -ne '1p')
49+ARGS=$(echo "$CONF" | sed -e '1d')
50+
951
1052grab_url_with () {
1153 url="${1:?internal error: grab_url_with: url required}"
@@ -104,7 +146,24 @@ if [ -n "$argument" ] && ! [ -f "$argument" ]; then
104146 inurl="$argument"
105147fi
106148
107−### tempdir.sh
149+# As a security measure refuse to proceed if mktemp is not available.
150+pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
151+
152+# Avoid issues with /tmp directory on Windows/Cygwin
153+cygwin=
154+cygwin=$(uname | sed -ne '/^CYGWIN/p')
155+if [ -n "$cygwin" ]; then
156+ TMPDIR=.
157+ export TMPDIR
158+fi
159+
160+THIS_TEMPDIR=
161+THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
162+readonly THIS_TEMPDIR
163+
164+trap 'exitcode=$?
165+ [ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
166+ exit $exitcode' 0 1 2 3 13 15
108167
109168if [ -n "$inurl" ]; then
110169 err "Attempting to fetch file from '$inurl'..."
wrappers/markdown2pdf.in → markdown2pdfrenamed+61−2
@@ -3,9 +3,68 @@
33REQUIRED="pdflatex"
44SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
55
6−### common.sh
6+THIS=${0##*/}
77
8−### tempdir.sh
8+NEWLINE='
9+'
10+
11+err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
12+errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
13+
14+usage () {
15+ err "$1 - $2" # short description
16+ err "See the $1(1) man page for usage."
17+}
18+
19+# Portable which(1).
20+pathfind () {
21+ oldifs="$IFS"; IFS=':'
22+ for _p in $PATH; do
23+ if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
24+ IFS="$oldifs"
25+ return 0
26+ fi
27+ done
28+ IFS="$oldifs"
29+ return 1
30+}
31+
32+for p in pandoc $REQUIRED; do
33+ pathfind $p || {
34+ err "You need '$p' to use this program!"
35+ exit 1
36+ }
37+done
38+
39+CONF=$(pandoc --dump-args "$@" 2>&1) || {
40+ errcode=$?
41+ echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
42+ [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
43+ exit $errcode
44+}
45+
46+OUTPUT=$(echo "$CONF" | sed -ne '1p')
47+ARGS=$(echo "$CONF" | sed -e '1d')
48+
49+
50+# As a security measure refuse to proceed if mktemp is not available.
51+pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
52+
53+# Avoid issues with /tmp directory on Windows/Cygwin
54+cygwin=
55+cygwin=$(uname | sed -ne '/^CYGWIN/p')
56+if [ -n "$cygwin" ]; then
57+ TMPDIR=.
58+ export TMPDIR
59+fi
60+
61+THIS_TEMPDIR=
62+THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
63+readonly THIS_TEMPDIR
64+
65+trap 'exitcode=$?
66+ [ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
67+ exit $exitcode' 0 1 2 3 13 15
968
1069texname=output
1170logfile=$THIS_TEMPDIR/log
wrappers/common.shdeleted−43
@@ -1,43 +0,0 @@
1−THIS=${0##*/}
2−
3−NEWLINE='
4−'
5−
6−err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
7−errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
8−
9−usage () {
10− err "$1 - $2" # short description
11− err "See the $1(1) man page for usage."
12−}
13−
14−# Portable which(1).
15−pathfind () {
16− oldifs="$IFS"; IFS=':'
17− for _p in $PATH; do
18− if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
19− IFS="$oldifs"
20− return 0
21− fi
22− done
23− IFS="$oldifs"
24− return 1
25−}
26−
27−for p in pandoc $REQUIRED; do
28− pathfind $p || {
29− err "You need '$p' to use this program!"
30− exit 1
31− }
32−done
33−
34−CONF=$(pandoc --dump-args "$@" 2>&1) || {
35− errcode=$?
36− echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
37− [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
38− exit $errcode
39−}
40−
41−OUTPUT=$(echo "$CONF" | sed -ne '1p')
42−ARGS=$(echo "$CONF" | sed -e '1d')
43−
wrappers/tempdir.shdeleted−18
@@ -1,18 +0,0 @@
1−# As a security measure refuse to proceed if mktemp is not available.
2−pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
3−
4−# Avoid issues with /tmp directory on Windows/Cygwin
5−cygwin=
6−cygwin=$(uname | sed -ne '/^CYGWIN/p')
7−if [ -n "$cygwin" ]; then
8− TMPDIR=.
9− export TMPDIR
10−fi
11−
12−THIS_TEMPDIR=
13−THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
14−readonly THIS_TEMPDIR
15−
16−trap 'exitcode=$?
17− [ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
18− exit $exitcode' 0 1 2 3 13 15