From 2ba5ff94833c9fee0fb2799e5440d8b235f9410e Mon Sep 17 00:00:00 2001 From: fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> Date: Sat, 9 Aug 2008 23:45:14 +0000 Subject: [PATCH] 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 --- .gitignore | 3 -- Makefile | 21 -------- wrappers/hsmarkdown.in => hsmarkdown | 0 wrappers/html2markdown.in => html2markdown | 63 +++++++++++++++++++++- wrappers/markdown2pdf.in => markdown2pdf | 63 +++++++++++++++++++++- wrappers/common.sh | 43 --------------- wrappers/tempdir.sh | 18 ------- 7 files changed, 122 insertions(+), 89 deletions(-) rename wrappers/hsmarkdown.in => hsmarkdown (100%) mode change 100644 => 100755 rename wrappers/html2markdown.in => html2markdown (74%) mode change 100644 => 100755 rename wrappers/markdown2pdf.in => markdown2pdf (62%) mode change 100644 => 100755 delete mode 100644 wrappers/common.sh delete mode 100644 wrappers/tempdir.sh 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 old mode 100644 new mode 100755 similarity index 100% rename from wrappers/hsmarkdown.in rename to hsmarkdown diff --git a/wrappers/html2markdown.in b/html2markdown old mode 100644 new mode 100755 similarity index 74% rename from wrappers/html2markdown.in rename to html2markdown index 0f4297128..0649e0478 --- 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 old mode 100644 new mode 100755 similarity index 62% rename from wrappers/markdown2pdf.in rename to markdown2pdf index 37be69469..ab0f3ae78 --- 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