aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile21
-rwxr-xr-x[-rw-r--r--]hsmarkdown (renamed from wrappers/hsmarkdown.in)0
-rwxr-xr-x[-rw-r--r--]html2markdown (renamed from wrappers/html2markdown.in)63
-rwxr-xr-x[-rw-r--r--]markdown2pdf (renamed from wrappers/markdown2pdf.in)63
-rw-r--r--wrappers/common.sh43
-rw-r--r--wrappers/tempdir.sh18
7 files changed, 122 insertions, 89 deletions
diff --git a/.gitignore b/.gitignore
index b06f96c78..86e2c499b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,9 +5,6 @@ INSTALL.*
.configure-stamp
man/man?/*.1
man/man?/*.html
-markdown2pdf
-html2markdown
-hsmarkdown
*.diff
pandoc.cabal.orig
diff --git a/Makefile b/Makefile
index 5442e3364..305c8debc 100644
--- a/Makefile
+++ b/Makefile
@@ -93,33 +93,12 @@ all: build-program
%.1: %.1.md $(MAIN)
./$(MAIN) -s -S -w man $< >$@ || rm -f $@
-define generate-shell-script
-echo >&2 "Generating $@..."; \
-awk ' \
- /^[ \t]*###+ / { \
- lead = $$0; sub(/[^ \t].*$$/, "", lead); \
- t = "$(dir $<)/"$$2; \
- while (getline line < t > 0) \
- print lead line; \
- next; \
- } \
- { print } \
-' <$< >$@
-chmod +x $@
-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 -q -r $(notdir $@) * -x $(notdir $@)
-.PHONY: wrappers
-wrappers: $(WRAPPERS)
-cleanup_files+=$(WRAPPERS)
-$(WRAPPERS): %: $(SRCDIR)/wrappers/%.in $(SRCDIR)/wrappers/*.sh
- @$(generate-shell-script)
-
.PHONY: configure
cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
ifdef GHC_PKG
diff --git a/wrappers/hsmarkdown.in b/hsmarkdown
index 17f970234..17f970234 100644..100755
--- a/wrappers/hsmarkdown.in
+++ b/hsmarkdown
diff --git a/wrappers/html2markdown.in b/html2markdown
index 0f4297128..0649e0478 100644..100755
--- a/wrappers/html2markdown.in
+++ b/html2markdown
@@ -5,7 +5,49 @@
REQUIRED="tidy"
SYNOPSIS="converts HTML from a URL, file, or STDIN to markdown-formatted text."
-### common.sh
+THIS=${0##*/}
+
+NEWLINE='
+'
+
+err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
+errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
+
+usage () {
+ err "$1 - $2" # short description
+ err "See the $1(1) man page for usage."
+}
+
+# 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
+}
+
+for p in pandoc $REQUIRED; do
+ pathfind $p || {
+ err "You need '$p' to use this program!"
+ exit 1
+ }
+done
+
+CONF=$(pandoc --dump-args "$@" 2>&1) || {
+ errcode=$?
+ echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
+ [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
+ exit $errcode
+}
+
+OUTPUT=$(echo "$CONF" | sed -ne '1p')
+ARGS=$(echo "$CONF" | sed -e '1d')
+
grab_url_with () {
url="${1:?internal error: grab_url_with: url required}"
@@ -104,7 +146,24 @@ if [ -n "$argument" ] && ! [ -f "$argument" ]; then
inurl="$argument"
fi
-### tempdir.sh
+# As a security measure refuse to proceed if mktemp is not available.
+pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
+
+# Avoid issues with /tmp directory on Windows/Cygwin
+cygwin=
+cygwin=$(uname | sed -ne '/^CYGWIN/p')
+if [ -n "$cygwin" ]; then
+ TMPDIR=.
+ export TMPDIR
+fi
+
+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
if [ -n "$inurl" ]; then
err "Attempting to fetch file from '$inurl'..."
diff --git a/wrappers/markdown2pdf.in b/markdown2pdf
index 37be69469..ab0f3ae78 100644..100755
--- a/wrappers/markdown2pdf.in
+++ b/markdown2pdf
@@ -3,9 +3,68 @@
REQUIRED="pdflatex"
SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
-### common.sh
+THIS=${0##*/}
-### tempdir.sh
+NEWLINE='
+'
+
+err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
+errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
+
+usage () {
+ err "$1 - $2" # short description
+ err "See the $1(1) man page for usage."
+}
+
+# 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
+}
+
+for p in pandoc $REQUIRED; do
+ pathfind $p || {
+ err "You need '$p' to use this program!"
+ exit 1
+ }
+done
+
+CONF=$(pandoc --dump-args "$@" 2>&1) || {
+ errcode=$?
+ echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
+ [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
+ exit $errcode
+}
+
+OUTPUT=$(echo "$CONF" | sed -ne '1p')
+ARGS=$(echo "$CONF" | sed -e '1d')
+
+
+# As a security measure refuse to proceed if mktemp is not available.
+pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
+
+# Avoid issues with /tmp directory on Windows/Cygwin
+cygwin=
+cygwin=$(uname | sed -ne '/^CYGWIN/p')
+if [ -n "$cygwin" ]; then
+ TMPDIR=.
+ export TMPDIR
+fi
+
+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
texname=output
logfile=$THIS_TEMPDIR/log
diff --git a/wrappers/common.sh b/wrappers/common.sh
deleted file mode 100644
index 9605f5940..000000000
--- a/wrappers/common.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-THIS=${0##*/}
-
-NEWLINE='
-'
-
-err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
-errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
-
-usage () {
- err "$1 - $2" # short description
- err "See the $1(1) man page for usage."
-}
-
-# 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
-}
-
-for p in pandoc $REQUIRED; do
- pathfind $p || {
- err "You need '$p' to use this program!"
- exit 1
- }
-done
-
-CONF=$(pandoc --dump-args "$@" 2>&1) || {
- errcode=$?
- echo "$CONF" | sed -e '/^pandoc \[OPTIONS\] \[FILES\]/,$d' >&2
- [ $errcode -eq 2 ] && usage "$THIS" "$SYNOPSIS"
- exit $errcode
-}
-
-OUTPUT=$(echo "$CONF" | sed -ne '1p')
-ARGS=$(echo "$CONF" | sed -e '1d')
-
diff --git a/wrappers/tempdir.sh b/wrappers/tempdir.sh
deleted file mode 100644
index f25ae7f51..000000000
--- a/wrappers/tempdir.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-# As a security measure refuse to proceed if mktemp is not available.
-pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
-
-# Avoid issues with /tmp directory on Windows/Cygwin
-cygwin=
-cygwin=$(uname | sed -ne '/^CYGWIN/p')
-if [ -n "$cygwin" ]; then
- TMPDIR=.
- export TMPDIR
-fi
-
-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