4if (echo "$@" | grep -q xetex); then
9SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
16err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
17errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
20 err "$1 - $2" # short description
22 pandoc -h | sed -ne '/--strict\|--preserve-tabs\|--tab-stop\|--parse-raw\|--toc\|--xetex\|--number-sections\|--include-in-header\|--include-before-body\|--include-after-body\|--custom-header\|--output\|--template\|--variable\|--help\|--version/p' >&2
27 oldifs="$IFS"; IFS=':'
29 if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
38for p in pandoc $REQUIRED; do
40 err "You need '$p' to use this program!"
45if (echo "$@" | grep -q -- "--help\|-h"); then
46 usage "$THIS" "$SYNOPSIS"
50CONF=$(pandoc --dump-args "$@") || exit $?
51OUTPUT=$(echo "$CONF" | sed -ne '1p')
52ARGS=$(echo "$CONF" | sed -e '1d')
54# As a security measure refuse to proceed if mktemp is not available.
55pathfind mktemp || { err "Couldn't find 'mktemp'; aborting."; exit 1; }
57# Avoid issues with /tmp directory on Windows/Cygwin
59cygwin=$(uname | sed -ne '/^CYGWIN/p')
60if [ -n "$cygwin" ]; then
66THIS_TEMPDIR="$(mktemp -d -t $THIS.XXXXXXXX)" || exit 1
70 [ -z "$THIS_TEMPDIR" ] || rm -rf "$THIS_TEMPDIR"
71 exit $exitcode' 0 1 2 3 13 15
74logfile=$THIS_TEMPDIR/log
76pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex
78if [ "$OUTPUT" = "-" ]; then
79 firstinfile="$(echo $ARGS | sed -ne '1p')"
80 firstinfilebase="${firstinfile%.*}"
81 destname="${firstinfilebase:-stdin}.pdf"
89 TEXINPUTS=$origdir:$TEXINPUTS:
93 while [ $finished = "no" ]; do
94 $latexprogram -interaction=batchmode $texname.tex >/dev/null || {
96 err "${THIS}: $latexprogram failed with error code $errcode"
97 [ -f $texname.log ] && {
98 err "${THIS}: error context:"
99 sed -ne '/^!/,/^[[:space:]]*$/p' \
100 -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
101 -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
102 if grep -q "File \`ucs.sty' not found" $texname.log; then
103 err "${THIS}: Please install the 'unicode' package from CTAN:"
104 err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
106 if grep -q "File \`ulem.sty' not found" $texname.log; then
107 err "${THIS}: Please install the 'ulem' package from CTAN:"
108 err " http://www.ctan.org/tex-archive/macros/latex/contrib/misc/ulem.sty"
113 if [ $runs -lt 3 ] &&
114 ((grep -q "Warning: There were undefined references." $texname.log) ||
115 (echo "$@" | grep -q -- "--toc\|--table-of-contents")); then
117 if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log; then
118 bibtex $texname 2>&1 >bibtex.err
119 if [ $runs -gt 2 ]; then
120 if grep -q "error message" bibtex.err ||
121 grep -q "Warning" bibtex.err; then
126 elif [ $runs -gt 1 ]; then # always run at least twice for pdf bookmarks
134mv -f $THIS_TEMPDIR/$texname.pdf "$destname"
136err "Created $destname"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list