git.iko.soy/typeable/pandoc
on master help sign in
Removed PDF writer from core pandoc, restored markdown2pdf.

+ Added markdown2pdf. + Removed Text/Pandoc/PDF.hs. + Removed references to PDF writer from Main.hs. + Removed references to PDF writer from pandoc.cabal. + Added markdown2pdf.1 to list of man pages in Setup.hs. + Added markdown2pdf.1.md man page source. + Added reference to markdown2pdf(1) in pandoc man page. + Added markdown2pdf to WRAPPERS in Makefile. + Removed mention of pdf writer from README; added markdown2pdf. + Added remarks on markdown2pdf dependencies to README.Debian. + Added markdown2pdf to web/index.txt.in. + Use markdown2pdf for pdf web demos. + Put markdown2pdf back into debian control and rules. + Added markdown2pdf to macports Portfile. + Added markdown2pdf to freebsd package. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1415 788f1e2b-df1e-0410-8736-df70ead52e1b

commit3d2ff3d0a8d6ee04e771d1261b1367d7a3f4efe3 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateWed 27 Aug 2008, 05:50 (18 years ago) parent4f14802
17 files changed+286−205
Main.hs+1−5 Makefile+3−3 README+42−27 README.Debian+6−14 Setup.hs+1−1 Text/Pandoc/PDF.hs−134 debian/control+6−6 debian/rules+1−1 freebsd/Makefile.in+3−3 freebsd/pkg-descr+3−3 macports/Portfile.in+3−3 man/man1/markdown2pdf.1.md+69 man/man1/pandoc.1.md+2−1 markdown2pdf+140 pandoc.cabal+1−2 web/demos+2−2 web/index.txt.in+3
Main.hs+1−5
@@ -32,7 +32,6 @@ writers.
3232module Main where
3333import Text.Pandoc
3434import Text.Pandoc.ODT
35−import Text.Pandoc.PDF
3635import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
3736import Text.Pandoc.Highlighting ( languages )
3837import System.Environment ( getArgs, getProgName, getEnvironment )
@@ -100,7 +99,6 @@ writers = [("native" , (writeDoc, ""))
10099 ,("opendocument" , (writeOpenDocument, defaultOpenDocumentHeader))
101100 ,("odt" , (writeOpenDocument, defaultOpenDocumentHeader))
102101 ,("latex" , (writeLaTeX, defaultLaTeXHeader))
103− ,("pdf" , (writeLaTeX, defaultLaTeXHeader))
104102 ,("context" , (writeConTeXt, defaultConTeXtHeader))
105103 ,("texinfo" , (writeTexinfo, ""))
106104 ,("man" , (writeMan, ""))
@@ -111,7 +109,7 @@ writers = [("native" , (writeDoc, ""))
111109 ]
112110
113111isNonTextOutput :: String -> Bool
114−isNonTextOutput = (`elem` ["odt", "pdf"])
112+isNonTextOutput = (`elem` ["odt"])
115113
116114-- | Writer for Pandoc native format.
117115writeDoc :: WriterOptions -> Pandoc -> String
@@ -433,7 +431,6 @@ defaultWriterName x =
433431 ".texinfo" -> "texinfo"
434432 ".db" -> "docbook"
435433 ".odt" -> "odt"
436− ".pdf" -> "pdf"
437434 ['.',y] | y `elem` ['1'..'9'] -> "man"
438435 _ -> "html"
439436
@@ -598,7 +595,6 @@ main = do
598595
599596 let writeOutput = case writerName' of
600597 "odt" -> saveOpenDocumentAsODT outputFile sourceDirRelative
601− "pdf" -> saveLaTeXAsPDF outputFile sourceDirRelative
602598 _ -> if outputFile == "-"
603599 then putStrLn
604600 else writeFile outputFile . (++ "\n")
Makefile+3−3
@@ -24,7 +24,7 @@ EXECSBASE := $(shell sed -ne 's/^[Ee]xecutable:\{0,1\}[[:space:]]*//p' $(CABAL))
2424#-------------------------------------------------------------------------------
2525# Install targets
2626#-------------------------------------------------------------------------------
27−WRAPPERS := html2markdown hsmarkdown
27+WRAPPERS := html2markdown hsmarkdown markdown2pdf
2828# Add .exe extensions if we're running Windows/Cygwin.
2929EXTENSION := $(shell uname | tr '[:upper:]' '[:lower:]' | \
3030 sed -ne 's/^cygwin.*$$/\.exe/p')
@@ -85,8 +85,8 @@ all: build-program
8585 ./$(MAIN) -s -w latex $< >$@ || rm -f $@
8686%.rtf: % $(MAIN)
8787 ./$(MAIN) -s -w rtf $< >$@ || rm -f $@
88−%.pdf: % $(MAIN)
89− ./$(MAIN) -w pdf -o $@ $< || rm -f $@
88+%.pdf: % $(MAIN) markdown2pdf
89+ sh ./markdown2pdf $< || rm -f $@
9090%.txt: %
9191 perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
9292
README+42−27
@@ -55,9 +55,8 @@ If you want to write to a file, use the `-o` option:
5555
5656 pandoc -o hello.html hello.txt
5757
58−[^1]: The exception is for non-text output formats, such as `odt`
59− and `pdf`. For output in these formats, an output file must be
60− specified explicitly.
58+[^1]: The exception is for `odt`. Since this is a binary output format,
59+ an output file must be specified explicitly.
6160
6261Note that you can specify multiple input files on the command line.
6362`pandoc` will concatenate them all (with blank lines between them)
@@ -82,28 +81,16 @@ To convert `hello.html` from html to markdown:
8281 pandoc -f html -t markdown hello.html
8382
8483Supported output formats include `markdown`, `latex`, `context`
85−(ConTeXt), `pdf`, `html`, `rtf` (rich text format), `rst`
84+(ConTeXt), `html`, `rtf` (rich text format), `rst`
8685(reStructuredText), `docbook` (DocBook XML), `opendocument`
8786(OpenDocument XML), `odt` (OpenOffice text document), `texinfo`, (GNU
8887Texinfo), `mediawiki` (MediaWiki markup), `man` (groff man), and `s5`
8988(which produces an HTML file that acts like powerpoint).
9089
91−Notes:
92−
93−- For `odt` output, you must have `zip` in the path. If you
94− don't have it installed, you can get the free [Info-ZIP].
95−
96−- For `pdf` output, you must have `pdflatex` and `bibtex` in the
97− path. You should also have the following LaTeX packages installed:
98− `unicode`, `fancyhdr` (if you have verbatim text in footnotes),
99− `graphicx` (if you use images), `array` (if you use tables), and
100− `ulem` (if you use strikeout text). If they are not already included
101− in your LaTeX distribution, you can get them from [CTAN]. A full
102− [TeX Live] or [MacTeX] distribution will have all of these packages.
103−
104− [Info-ZIP]: http://www.info-zip.org/Zip.html
105− [TeX Live]: http://www.tug.org/texlive/
106− [MacTeX]: http://www.tug.org/mactex/
90+For `odt` output, you must have `zip` in the path. If you
91+don't have it installed, you can get the free [Info-ZIP].
92+
93+[Info-ZIP]: http://www.info-zip.org/Zip.html
10794
10895Supported input formats include `markdown`, `html`, `latex`, and `rst`.
10996Note that the `rst` reader only parses a subset of reStructuredText
@@ -148,12 +135,38 @@ then convert the output back to the local encoding.
148135Shell scripts
149136=============
150137
151−Two shell scripts, `html2markdown` and `hsmarkdown`, are included in
152−the standard Pandoc installation. (They are not included in the Windows
153−binary package, as they require a POSIX shell, but they may be used in
154−Windows under Cygwin.)
138+Three shell scripts, `markdown2pdf`, `html2markdown`, and `hsmarkdown`,
139+are included in the standard Pandoc installation. (They are not included
140+in the Windows binary package, as they require a POSIX shell, but they
141+may be used in Windows under Cygwin.)
142+
143+1. `markdown2pdf` produces a PDF file from markdown-formatted
144+ text, using `pandoc` and `pdflatex`. The default
145+ behavior of `markdown2pdf` is to create a file with the same
146+ base name as the first argument and the extension `pdf`; thus,
147+ for example,
148+
149+ markdown2pdf sample.txt endnotes.txt
150+
151+ will produce `sample.pdf`. (If `sample.pdf` exists already,
152+ it will be backed up before being overwritten.) An output file
153+ name can be specified explicitly using the `-o` option:
154+
155+ markdown2pdf -o book.pdf chap1 chap2
156+
157+ If no input file is specified, input will be taken from stdin.
158+ All of `pandoc`'s options will work with `markdown2pdf` as well.
159+
160+ `markdown2pdf` assumes that `pdflatex` is in the path. It also
161+ assumes that the following LaTeX packages are available:
162+ `unicode`, `fancyhdr` (if you have verbatim text in footnotes),
163+ `graphicx` (if you use images), `array` (if you use tables),
164+ and `ulem` (if you use strikeout text). If they are not already
165+ included in your LaTeX distribution, you can get them from
166+ [CTAN]. A full [TeX Live] or [MacTeX] distribution will have all of
167+ these packages.
155168
156−1. `html2markdown` grabs a web page from a file or URL and converts
169+2. `html2markdown` grabs a web page from a file or URL and converts
157170 it to markdown-formatted text, using `tidy` and `pandoc`.
158171
159172 All of `pandoc`'s options will work with `html2markdown` as well.
@@ -182,7 +195,7 @@ Windows under Cygwin.)
182195 It uses [`iconv`] for character encoding conversions; if `iconv`
183196 is absent, it will still work, but it will treat everything as UTF-8.
184197
185−2. `hsmarkdown` is designed to be used as a drop-in replacement for
198+3. `hsmarkdown` is designed to be used as a drop-in replacement for
186199 `Markdown.pl`. It forces `pandoc` to convert from markdown to
187200 HTML, and to use the `--strict` flag for maximal compliance with
188201 official markdown syntax. (All of Pandoc's syntax extensions and
@@ -202,6 +215,8 @@ Windows under Cygwin.)
202215[HTML Tidy]: http://tidy.sourceforge.net/
203216[`iconv`]: http://www.gnu.org/software/libiconv/
204217[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
218+[TeX Live]: http://www.tug.org/texlive/
219+[MacTeX]: http://www.tug.org/mactex/
205220
206221Command-line options
207222====================
@@ -227,7 +242,7 @@ For further documentation, see the `pandoc(1)` man page.
227242`-o` or `--output` *filename*
228243: sends output to *filename*. If this option is not specified,
229244 or if its argument is `-`, output will be sent to stdout.
230− (Exception: if the output format is `odt` or `pdf`, output to stdout
245+ (Exception: if the output format is `odt`, output to stdout
231246 is disabled.)
232247
233248`-p` or `--preserve-tabs`
README.Debian+6−14
@@ -1,17 +1,9 @@
1−Notes to Debian users:
1+Notes to Debian users on "suggested" dependencies:
22
3−1. `markdown2pdf` has been removed, since pandoc now includes `pdf`
4− as a writer option. You can replace
3+If you intend to use the markdown2pdf script, you should install
4+texlive-latex-recommended (or, if you use teTeX, tetex-extra). This
5+provides LaTeX packages that are needed by markdown2pdf.
56
6− markdown2pdf foo.txt
7−
8− with
9−
10− pandoc foo.txt -o foo.pdf
11−
12− Note that unlike `markdown2npdf`, `pandoc` requires that the output
13− filename be specified explicitly.
14−
15−2. If you intend to use the html2markdown script, you should install
16− tidy, plus either wget or w3m.
7+If you intend to use the html2markdown script, you should install
8+tidy, plus either wget or w3m.
179
Setup.hs+1−1
@@ -50,7 +50,7 @@ makeReferenceODT sources = do
5050
5151-- | Build man pages from markdown sources in man/man1/.
5252makeManPages _ _ _ _ = do
53− mapM makeManPage ["pandoc.1", "hsmarkdown.1", "html2markdown.1"]
53+ mapM makeManPage ["pandoc.1", "hsmarkdown.1", "html2markdown.1", "markdown2pdf.1"]
5454 return ()
5555
5656-- | Build a man page from markdown source in man/man1.
Text/Pandoc/PDF.hsdeleted−134
@@ -1,134 +0,0 @@
1−{-
2−Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
3−
4−This program is free software; you can redistribute it and/or modify
5−it under the terms of the GNU General Public License as published by
6−the Free Software Foundation; either version 2 of the License, or
7−(at your option) any later version.
8−
9−This program is distributed in the hope that it will be useful,
10−but WITHOUT ANY WARRANTY; without even the implied warranty of
11−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12−GNU General Public License for more details.
13−
14−You should have received a copy of the GNU General Public License
15−along with this program; if not, write to the Free Software
16−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17−-}
18−
19−{- |
20− Module : Text.Pandoc.PDF
21− Copyright : Copyright (C) 2006-7 John MacFarlane
22− License : GNU GPL, version 2 or above
23−
24− Maintainer : John MacFarlane <jgm@berkeley.edu>
25− Stability : alpha
26− Portability : portable
27−
28−Functions for producing a PDF file from LaTeX.
29−-}
30−module Text.Pandoc.PDF ( saveLaTeXAsPDF ) where
31−import Data.List ( isInfixOf )
32−import System.Directory
33−import System.FilePath ( (</>), (<.>), takeBaseName )
34−import System.Process ( runProcess, waitForProcess )
35−import System.Exit
36−import System.Environment ( getEnvironment )
37−import Text.Pandoc.Shared ( withTempDir )
38−import Prelude hiding ( writeFile, readFile, putStrLn )
39−import System.IO ( stderr, openFile, IOMode (..), hClose )
40−import System.IO.UTF8
41−
42−-- | Produce an PDF file from LaTeX.
43−saveLaTeXAsPDF :: FilePath -- ^ Pathname of PDF file to be produced.
44− -> FilePath -- ^ Relative directory of source file.
45− -> String -- ^ LaTeX document.
46− -> IO ()
47−saveLaTeXAsPDF destinationPDFPath sourceDirRelative latex = do
48− -- check for pdflatex and bibtex in path:
49− latexPathMaybe <- findExecutable "pdflatex"
50− bibtexPathMaybe <- findExecutable "bibtex"
51− let latexPath = case latexPathMaybe of
52− Nothing -> error $ "The 'pdflatex' command, which is needed to build a PDF file, was not found."
53− Just x -> x
54− let bibtexPath = case bibtexPathMaybe of
55− Nothing -> error $ "The 'bibtex' command, which is needed to build an PDF file, was not found."
56− Just x -> x
57− sourceDirAbsolute <- getCurrentDirectory >>= return . (</> sourceDirRelative) >>= canonicalizePath
58− withTempDir "pandoc-pdf" $ \tempDir -> do
59− env <- getEnvironment
60− let env' = ("TEXINPUTS", ".:" ++ sourceDirAbsolute ++ ":") : env
61− let baseName = "input"
62− writeFile (tempDir </> baseName <.> "tex") latex
63− let runLatex = runProgram latexPath ["-interaction=nonstopmode", baseName] tempDir env'
64− let runBibtex = runProgram bibtexPath [baseName] tempDir env'
65− messages1 <- runLatex
66− let logPath = tempDir </> baseName <.> "log"
67− tocExists <- doesFileExist (tempDir </> baseName <.> "toc")
68− logContents <- readFile logPath
69− let undefinedRefs = "There were undefined references" `isInfixOf` logContents
70− let needsBibtex = "itation" `isInfixOf` logContents
71− if needsBibtex
72− then runBibtex >>= hPutStr stderr . unlines
73− else return ()
74− if tocExists || undefinedRefs
75− then do
76− messages2 <- runLatex
77− logContents' <- readFile logPath
78− let stillUndefinedRefs = "There were undefined references" `isInfixOf` logContents'
79− if stillUndefinedRefs
80− then runLatex >>= hPutStr stderr . unlines
81− else hPutStr stderr $ unlines messages2
82− else
83− hPutStr stderr $ unlines messages1
84− let pdfPath = tempDir </> baseName <.> "pdf"
85− pdfExists <- doesFileExist pdfPath
86− if pdfExists
87− then copyFile pdfPath destinationPDFPath
88− else error "The PDF could not be created."
89−
90−runProgram :: FilePath -- ^ pathname of executable
91− -> [String] -- ^ arguments
92− -> FilePath -- ^ working directory
93− -> [(String, String)] -- ^ environment
94− -> IO [String]
95−runProgram cmdPath arguments workingDir env = do
96− let runOutputPath = workingDir </> "output" <.> "tmp"
97− runOutput <- openFile runOutputPath WriteMode
98− ph <- runProcess cmdPath arguments (Just workingDir) (Just env) Nothing (Just runOutput) (Just runOutput)
99− ec <- waitForProcess ph -- requires compilation with -threaded
100− hClose runOutput
101− case ec of
102− ExitSuccess -> return []
103− _ -> do
104− output <- readFile runOutputPath
105− if (takeBaseName cmdPath) == "bibtex"
106− then return $! lines output
107− else do
108− return $!
109− (if "`ucs.sty' not found" `isInfixOf` output
110− then ["Please install the 'unicode' package from CTAN:",
111− " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"]
112− else []) ++
113− (if "`ulem.sty' not found" `isInfixOf` output
114− then ["Please install the 'ulem' package from CTAN:",
115− " http://www.ctan.org/tex-archive/macros/latex/contrib/misc/"]
116− else []) ++
117− (if "`graphicx.sty' not found" `isInfixOf` output
118− then ["Please install the 'graphicx' package from CTAN:",
119− " http://www.ctan.org/tex-archive/macros/latex/required/graphics/"]
120− else []) ++
121− (if "`fancyhdr.sty' not found" `isInfixOf` output
122− then ["Please install the 'fancyhdr' package from CTAN:",
123− " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/"]
124− else []) ++
125− (if "`array.sty' not found" `isInfixOf` output
126− then ["Please install the 'array' package from CTAN:",
127− " http://www.ctan.org/tex-archive/macros/latex/required/tools/"]
128− else []) ++
129− (filter isUseful $ lines output)
130− where isUseful ln = take 1 ln == "!" ||
131− take 2 ln == "l." ||
132− "Error" `isInfixOf` ln ||
133− "error" `isInfixOf` ln
134−
debian/control+6−6
@@ -18,7 +18,7 @@ Description: general markup converter
1818 Pandoc is a Haskell library for converting from one markup format to
1919 another, and a command-line tool that uses this library. It can read
2020 markdown and (subsets of) reStructuredText, HTML, and LaTeX, and it
21− can write markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF,
21+ can write markdown, reStructuredText, HTML, LaTeX, ConTeXt,
2222 DocBook XML, OpenDocument XML, ODT, RTF, GNU Texinfo, MediaWiki markup,
2323 groff man pages, and S5 HTML slide shows.
2424 .
@@ -26,7 +26,7 @@ Description: general markup converter
2626 tables, definition lists, and other features. A compatibility mode is
2727 provided for those who need a drop-in replacement for Markdown.pl.
2828 Included wrapper scripts make it easy to convert markdown documents to
29− PDF or ODT format and to convert web pages to markdown documents.
29+ PDF and to convert web pages to markdown documents.
3030 .
3131 In contrast to existing tools for converting markdown to HTML, which
3232 use regex substitutions, pandoc has a modular design: it consists of a
@@ -44,7 +44,7 @@ Description: general markup converter
4444 Pandoc is a Haskell library for converting from one markup format to
4545 another, and a command-line tool that uses this library. It can read
4646 markdown and (subsets of) reStructuredText, HTML, and LaTeX, and it
47− can write markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF,
47+ can write markdown, reStructuredText, HTML, LaTeX, ConTeXt,
4848 DocBook XML, OpenDocument XML, ODT, RTF, GNU Texinfo, MediaWiki markup,
4949 groff man pages, and S5 HTML slide shows.
5050 .
@@ -52,7 +52,7 @@ Description: general markup converter
5252 tables, definition lists, and other features. A compatibility mode is
5353 provided for those who need a drop-in replacement for Markdown.pl.
5454 Included wrapper scripts make it easy to convert markdown documents to
55− PDF or ODT format and to convert web pages to markdown documents.
55+ PDF and to convert web pages to markdown documents.
5656 .
5757 In contrast to existing tools for converting markdown to HTML, which
5858 use regex substitutions, pandoc has a modular design: it consists of a
@@ -70,7 +70,7 @@ Description: general markup converter
7070 Pandoc is a Haskell library for converting from one markup format to
7171 another, and a command-line tool that uses this library. It can read
7272 markdown and (subsets of) reStructuredText, HTML, and LaTeX, and it
73− can write markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF,
73+ can write markdown, reStructuredText, HTML, LaTeX, ConTeXt,
7474 DocBook XML, OpenDocument XML, ODT, RTF, GNU Texinfo, MediaWiki markup,
7575 groff man pages, and S5 HTML slide shows.
7676 .
@@ -78,7 +78,7 @@ Description: general markup converter
7878 tables, definition lists, and other features. A compatibility mode is
7979 provided for those who need a drop-in replacement for Markdown.pl.
8080 Included wrapper scripts make it easy to convert markdown documents to
81− PDF or ODT format and to convert web pages to markdown documents.
81+ PDF and to convert web pages to markdown documents.
8282 .
8383 In contrast to existing tools for converting markdown to HTML, which
8484 use regex substitutions, pandoc has a modular design: it consists of a
debian/rules+1−1
@@ -111,7 +111,7 @@ binary-arch: build install
111111 dh_installexamples -a
112112 dh_installman -a
113113 dh_link -a
114− dh_strip -a -Xhtml2
114+ dh_strip -a -Xhtml2 -Xhsmarkdown -Xmarkdown2
115115 dh_compress -a
116116 dh_fixperms -a
117117 dh_installdeb -a
freebsd/Makefile.in+3−3
@@ -16,14 +16,14 @@ COMMENT= A general markup converter
1616BUILD_DEPENDS= ghc>=6.6:${PORTSDIR}/lang/ghc
1717
1818MANCOMPRESSED= no
19−MAN1= pandoc.1 html2markdown.1 hsmarkdown.1
19+MAN1= pandoc.1 markdown2pdf.1 html2markdown.1 hsmarkdown.1
2020
2121USE_GMAKE= yes
2222USE_PERL5= yes
2323
24−PLIST_FILES= bin/pandoc bin/html2markdown bin/hsmarkdown
24+PLIST_FILES= bin/pandoc bin/markdown2pdf bin/html2markdown bin/hsmarkdown
2525PORTDOCS= BUGS README README.html
26−SCRIPTS= hsmarkdown html2markdown
26+SCRIPTS= markdown2pdf hsmarkdown html2markdown
2727
2828do-install:
2929 @${INSTALL_PROGRAM} ${WRKSRC}/dist/build/pandoc/pandoc ${PREFIX}/bin
freebsd/pkg-descr+3−3
@@ -1,14 +1,14 @@
11Pandoc is a command-line tool for converting from one markup format
22to another. It can read markdown and (subsets of) reStructuredText,
33HTML, and LaTeX, and it can write markdown, reStructuredText, HTML,
4−LaTeX, ConTeXt, PDF, DocBook XML, OpenDocument XML, ODT, RTF, GNU
4+LaTeX, ConTeXt, DocBook XML, OpenDocument XML, ODT, RTF, GNU
55Texinfo, MediaWiki markup, groff man pages, and S5 HTML slide shows.
66
77Pandoc extends standard markdown syntax with footnotes, embedded LaTeX,
88and other features. A compatibility mode is provided for those who
99need a drop-in replacement for Markdown.pl. Included wrapper scripts
10−make it easy to convert markdown documents to PDF or ODT format and to
11−convert web pages to markdown documents.
10+make it easy to convert markdown documents to PDF and to convert web
11+pages to markdown documents.
1212
1313In contrast to existing tools for converting markdown to HTML, which
1414use regex substitutions, pandoc has a modular design: it consists of a
macports/Portfile.in+3−3
@@ -11,7 +11,7 @@ long_description \
1111 Pandoc is a command-line tool for converting from one markup format \
1212 to another. It can read markdown and (subsets of) reStructuredText, \
1313 HTML, and LaTeX, and it can write markdown, reStructuredText, HTML, \
14− LaTeX, ConTeXt, PDF, DocBook XML, OpenDocument XML, ODT, RTF, Texinfo, \
14+ LaTeX, ConTeXt, DocBook XML, OpenDocument XML, ODT, RTF, Texinfo, \
1515 MediaWiki markup, groff man, and S5 HTML slide shows.
1616
1717homepage http://johnmacfarlane.net/pandoc/
@@ -40,7 +40,7 @@ destroot {
4040 xinstall -m 755 ${worksrcpath}/unregister.sh \
4141 ${destroot}${prefix}/libexec/${name}-${version}
4242 # install shell scripts:
43− xinstall -m 755 -W ${worksrcpath} html2markdown hsmarkdown \
43+ xinstall -m 755 -W ${worksrcpath} html2markdown hsmarkdown markdown2pdf \
4444 ${destroot}${prefix}/bin
4545 # install data file:
4646 xinstall -d ${destroot}${prefix}/share/${name}
@@ -51,7 +51,7 @@ destroot {
5151 xinstall -m 644 -W ${worksrcpath} README README.html COPYRIGHT BUGS \
5252 ${destroot}${prefix}/share/doc/${name}
5353 xinstall -m 644 -W ${worksrcpath}/man/man1 pandoc.1 hsmarkdown.1 \
54− html2markdown.1 \
54+ markdown2pdf.1 html2markdown.1 \
5555 ${destroot}${prefix}/share/man/man1
5656}
5757
man/man1/markdown2pdf.1.mdnew file+69
@@ -0,0 +1,69 @@
1+% MARKDOWN2PDF(1) Pandoc User Manuals
2+% John MacFarlane and Recai Oktas
3+% January 8, 2008
4+
5+# NAME
6+
7+markdown2pdf - converts markdown-formatted text to PDF, using pdflatex
8+
9+# SYNOPSIS
10+
11+markdown2pdf [*options*] [*input-file*]...
12+
13+# DESCRIPTION
14+
15+`markdown2pdf` converts *input-file* (or text from standard
16+input) from markdown-formatted plain text to PDF, using `pdflatex`.
17+If no output filename is specified (using the `-o` option),
18+the name of the output file is derived from the input file; thus, for
19+example, if the input file is *hello.txt*, the output file will be
20+*hello.pdf*. If the input is read from STDIN and no output filename
21+is specified, the output file will be named *stdin.pdf*. If multiple
22+input files are specified, they will be concatenated before conversion,
23+and the name of the output file will be derived from the first input file.
24+
25+Input is assumed to be in the UTF-8 character encoding. If your
26+local character encoding is not UTF-8, you should pipe input
27+through `iconv`:
28+
29+ iconv -t utf-8 input.txt | markdown2pdf
30+
31+`markdown2pdf` assumes that the `unicode`, `array`, `fancyvrb`,
32+`graphicx`, and `ulem` packages are in latex's search path. If these
33+packages are not included in your latex setup, they can be obtained from
34+<http://ctan.org>.
35+
36+# OPTIONS
37+
38+`markdown2pdf` is a wrapper around `pandoc`, so all of
39+`pandoc`'s options can be used with `markdown2pdf` as well.
40+See `pandoc`(1) for a complete list.
41+The following options are most relevant:
42+
43+-o *FILE*, \--output=*FILE*
44+: Write output to *FILE*.
45+
46+\--strict
47+: Use strict markdown syntax, with no extensions or variants.
48+
49+-N, \--number-sections
50+: Number section headings in LaTeX output. (Default is not to number them.)
51+
52+-H *FILE*, \--include-in-header=*FILE*
53+: Include (LaTeX) contents of *FILE* at the end of the header. Implies
54+ `-s`.
55+
56+-B *FILE*, \--include-before-body=*FILE*
57+: Include (LaTeX) contents of *FILE* at the beginning of the document body.
58+
59+-A *FILE*, \--include-after-body=*FILE*
60+: Include (LaTeX) contents of *FILE* at the end of the document body.
61+
62+-C *FILE*, \--custom-header=*FILE*
63+: Use contents of *FILE*
64+ as the LaTeX document header (overriding the default header, which can be
65+ printed using `pandoc -D latex`). Implies `-s`.
66+
67+# SEE ALSO
68+
69+`pandoc`(1), `pdflatex`(1)
man/man1/pandoc.1.md+2−1
@@ -197,7 +197,8 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
197197# SEE ALSO
198198
199199`hsmarkdown`(1),
200−`html2markdown`(1).
200+`html2markdown`(1),
201+`markdown2pdf` (1).
201202The *README* file distributed with Pandoc contains full documentation.
202203
203204The Pandoc source code and all documentation may be downloaded from
markdown2pdfnew file+140
@@ -0,0 +1,140 @@
1+#!/bin/sh -e
2+
3+REQUIRED="pdflatex"
4+SYNOPSIS="converts markdown-formatted text to PDF, using pdflatex."
5+
6+THIS=${0##*/}
7+
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
68+
69+texname=output
70+logfile=$THIS_TEMPDIR/log
71+
72+pandoc -s -r markdown -w latex "$@" -o $THIS_TEMPDIR/$texname.tex
73+
74+if [ "$OUTPUT" = "-" ]; then
75+ firstinfile="$(echo $ARGS | sed -ne '1p')"
76+ firstinfilebase="${firstinfile%.*}"
77+ destname="${firstinfilebase:-stdin}.pdf"
78+else
79+ destname="$OUTPUT"
80+fi
81+
82+(
83+ origdir=$(pwd)
84+ cd $THIS_TEMPDIR
85+ TEXINPUTS=$origdir:$TEXINPUTS:
86+ export TEXINPUTS
87+ finished=no
88+ runs=0
89+ while [ $finished = "no" ]; do
90+ pdflatex -interaction=batchmode $texname.tex >/dev/null || {
91+ errcode=$?
92+ err "${THIS}: pdfLaTeX failed with error code $errcode"
93+ [ -f $texname.log ] && {
94+ err "${THIS}: error context:"
95+ sed -ne '/^!/,/^[[:space:]]*$/p' \
96+ -ne '/^[Ll]a[Tt]e[Xx] [Ww]arning/,/^[[:space:]]*$/p' \
97+ -ne '/^[Ee]rror/,/^[[:space:]]*$/p' $texname.log >&2
98+ if grep -q "File \`ucs.sty' not found" $texname.log; then
99+ err "${THIS}: Please install the 'unicode' package from CTAN:"
100+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
101+ fi
102+ if grep -q "File \`ulem.sty' not found" $texname.log; then
103+ err "${THIS}: Please install the 'ulem' package from CTAN:"
104+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/misc/ulem.sty"
105+ fi
106+ }
107+ exit $errcode
108+ }
109+ if [ $runs -lt 3 ] &&
110+ ((grep -q "LaTeX Warning: There were undefined references." $texname.log) ||
111+ (echo "$@" | grep -q -- "--toc\|--table-of-contents")); then
112+ runs=$(($runs + 1))
113+ if grep -q "LaTeX Warning:.*[Cc]itation" $texname.log; then
114+ bibtex $texname 2>&1 >bibtex.err
115+ if [ $runs -gt 2 ]; then
116+ if grep -q "error message" bibtex.err ||
117+ grep -q "Warning" bibtex.err; then
118+ cat bibtex.err >&2
119+ fi
120+ fi
121+ fi
122+ else
123+ finished=yes
124+ fi
125+ done
126+) || exit $?
127+
128+is_target_exists=
129+if [ -f "$destname" ]; then
130+ is_target_exists=1
131+ mv "$destname" "$destname~"
132+fi
133+
134+mv -f $THIS_TEMPDIR/$texname.pdf "$destname"
135+
136+errn "Created $destname"
137+[ -z "$is_target_exists" ] || {
138+ errn " (previous file has been backed up as $destname~)"
139+}
140+err .
pandoc.cabal+1−2
@@ -18,7 +18,7 @@ Description: Pandoc is a Haskell library for converting from one markup
1818 this library. It can read markdown and (subsets of)
1919 reStructuredText, HTML, and LaTeX, and it can write
2020 markdown, reStructuredText, HTML, LaTeX, ConTeXt, Docbook,
21− OpenDocument, ODT, PDF, RTF, MediaWiki, groff man pages, and
21+ OpenDocument, ODT, RTF, MediaWiki, groff man pages, and
2222 S5 HTML slide shows.
2323 .
2424 Pandoc extends standard markdown syntax with footnotes,
@@ -159,7 +159,6 @@ Library
159159 Text.Pandoc.CharacterReferences,
160160 Text.Pandoc.Shared,
161161 Text.Pandoc.ODT,
162− Text.Pandoc.PDF,
163162 Text.Pandoc.LaTeXMathML,
164163 Text.Pandoc.DefaultHeaders,
165164 Text.Pandoc.Highlighting,
web/demos+2−2
@@ -61,11 +61,11 @@ click on the name of the output file:
6161
626213. From markdown to PDF:
6363
64−@ pandoc @@README@@ -o @@example13.pdf@@
64+@ markdown2pdf @@README@@ -o @@example13.pdf@@
6565
666614. PDF with numbered sections and a custom LaTeX header:
6767
68−@ pandoc -N -C @@myheader.tex@@ @@README@@ -o @@example14.pdf@@
68+@ markdown2pdf -N -C @@myheader.tex@@ @@README@@ -o @@example14.pdf@@
6969
7070[xmlto]: http://cyberelk.net/tim/xmlto/
7171
web/index.txt.in+3
@@ -34,6 +34,8 @@ Pandoc features
3434 + Compatibility mode to turn off syntax entensions and emulate
3535 `Markdown.pl`.
3636- Convenient wrapper scripts:
37+ + `markdown2pdf` converts directly from markdown to PDF, using
38+ `pdflatex`.
3739 + `html2markdown` makes it easy to produce a markdown version
3840 of any web page.
3941 + `hsmarkdown` is a drop-in replacement for `Markdown.pl`.
@@ -49,6 +51,7 @@ or [try pandoc on the web](/pandoc/try).
4951- [Demonstrations](examples.html)
5052- Man pages
5153 - [`pandoc(1)`](pandoc.1.html)
54+ - [`markdown2pdf(1)`](markdown2pdf.1.html)
5255 - [`html2markdown(1)`](html2markdown.1.html)
5356 - [`hsmarkdown(1)`](hsmarkdown.1.html)
5457- [Library documentation](doc/pandoc/index.html) (for Haskell programmers)