git.iko.soy/typeable/pandoc
on master help sign in
Added 'beamer' as an output format.
ea39a60John MacFarlane
README+29−18
@@ -14,10 +14,10 @@ Pandoc is a [Haskell] library for converting from one markup format to
14another, and a command-line tool that uses this library. It can read
14another, and a command-line tool that uses this library. It can read
15[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
15[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
16and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
16and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
17−[HTML], [LaTeX], [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT],
17+[HTML], [LaTeX], [LaTeX beamer], [ConTeXt], [RTF], [DocBook XML],
18−[GNU Texinfo], [MediaWiki markup], [EPUB], [Textile], [groff man] pages,
18+[OpenDocument XML], [ODT], [GNU Texinfo], [MediaWiki markup], [EPUB],
19−[Emacs Org-Mode], [AsciiDoc], and [Slidy], [DZSlides], or [S5] HTML
19+[Textile], [groff man] pages, [Emacs Org-Mode], [AsciiDoc], and [Slidy],
20−slide shows.
20+[DZSlides], or [S5] HTML slide shows.
21
21
22Pandoc's enhanced version of markdown includes syntax for footnotes,
22Pandoc's enhanced version of markdown includes syntax for footnotes,
23tables, flexible ordered lists, definition lists, delimited code blocks,
23tables, flexible ordered lists, definition lists, delimited code blocks,
@@ -151,20 +151,19 @@ Options
151`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
151`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
152: Specify output format. *FORMAT* can be `native` (native Haskell),
152: Specify output format. *FORMAT* can be `native` (native Haskell),
153 `json` (JSON version of native AST), `plain` (plain text),
153 `json` (JSON version of native AST), `plain` (plain text),
154− `markdown` (markdown), `rst` (reStructuredText),
154+ `markdown` (markdown), `rst` (reStructuredText), `html` (HTML), `latex`
155− `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man),
155+ (LaTeX), `beamer` (LaTeX beamer), `context` (ConTeXt), `man` (groff
156− `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs
156+ man), `mediawiki` (MediaWiki markup), `textile` (Textile), `org`
157− Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML),
157+ (Emacs Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML),
158 `opendocument` (OpenDocument XML), `odt` (OpenOffice text document),
158 `opendocument` (OpenDocument XML), `odt` (OpenOffice text document),
159 `epub` (EPUB book), `asciidoc` (AsciiDoc), `slidy` (Slidy HTML and
159 `epub` (EPUB book), `asciidoc` (AsciiDoc), `slidy` (Slidy HTML and
160 javascript slide show), `dzslides` (HTML5 + javascript slide show),
160 javascript slide show), `dzslides` (HTML5 + javascript slide show),
161− `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
161+ `s5` (S5 HTML and javascript slide show), or `rtf` (rich text format).
162− format). Note that `odt` and `epub` output will not be directed to
162+ Note that `odt` and `epub` output will not be directed to *stdout*; an
163− *stdout*; an output filename must be specified using the `-o/--output`
163+ output filename must be specified using the `-o/--output` option. If
164− option. If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
164+ `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`, the output
165− the output will be rendered as literate Haskell source:
165+ will be rendered as literate Haskell source: see [Literate Haskell
166− see [Literate Haskell support](#literate-haskell-support),
166+ support](#literate-haskell-support), below.
167− below.
168
167
169`-s`, `--standalone`
168`-s`, `--standalone`
170: Produce output with an appropriate header and footer (e.g. a
169: Produce output with an appropriate header and footer (e.g. a
@@ -580,6 +579,14 @@ depending on the output format, but include:
580 `http://www.w3.org/Talks/Tools/Slidy2`)
579 `http://www.w3.org/Talks/Tools/Slidy2`)
581`s5-url`
580`s5-url`
582: base URL for S5 documents (defaults to `ui/default`)
581: base URL for S5 documents (defaults to `ui/default`)
582+`font-size`
583+: font size (10pt, 11pt, 12pt) for LaTeX and beamer documents
584+`documentclass`
585+: document class for LaTeX documents
586+`theme`
587+: theme for beamer documents
588+`colortheme`
589+: colortheme for beamer documents
583
590
584Variables may be set at the command line using the `-V/--variable`
591Variables may be set at the command line using the `-V/--variable`
585option. This allows users to include custom variables in their
592option. This allows users to include custom variables in their
@@ -1903,12 +1910,14 @@ document with an appropriate header:
1903The bibliography will be inserted after this header.
1910The bibliography will be inserted after this header.
1904
1911
1905
1912
1906−Producing HTML slide shows with Pandoc
1913+Producing slide shows with Pandoc
1907−======================================
1914+=================================
1908
1915
1909You can use Pandoc to produce an HTML + javascript slide presentation
1916You can use Pandoc to produce an HTML + javascript slide presentation
1910that can be viewed via a web browser. There are three ways to do this,
1917that can be viewed via a web browser. There are three ways to do this,
1911−using [S5], [DZSlides], or [Slidy].
1918+using [S5], [DZSlides], or [Slidy]. You can also produce a PDF slide
1919+show using [LaTeX beamer]: just pass the `--beamer` option to
1920+`markdown2pdf`.
1912
1921
1913Here's the markdown source for a simple slide show, `eating.txt`:
1922Here's the markdown source for a simple slide show, `eating.txt`:
1914
1923
@@ -1946,6 +1955,7 @@ for DZSlides.
1946
1955
1947A title page is constructed automatically from the document's title
1956A title page is constructed automatically from the document's title
1948block. Each level-one header and horizontal rule begins a new slide.
1957block. Each level-one header and horizontal rule begins a new slide.
1958+(If beamer is used, all headers begin a new slide.)
1949
1959
1950For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
1960For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
1951option embeds a link to javascripts and CSS files, which are assumed to
1961option embeds a link to javascripts and CSS files, which are assumed to
@@ -2043,6 +2053,7 @@ Christopher Sawicki, Kelsey Hightower.
2043[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
2053[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
2044[HTML]: http://www.w3.org/TR/html40/
2054[HTML]: http://www.w3.org/TR/html40/
2045[LaTeX]: http://www.latex-project.org/
2055[LaTeX]: http://www.latex-project.org/
2056+[LaTeX beamer]: http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer
2046[ConTeXt]: http://www.pragma-ade.nl/
2057[ConTeXt]: http://www.pragma-ade.nl/
2047[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
2058[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
2048[DocBook XML]: http://www.docbook.org/
2059[DocBook XML]: http://www.docbook.org/
src/Text/Pandoc.hs+2
@@ -181,6 +181,8 @@ writers = [("native" , writeNative)
181 ,("latex" , writeLaTeX)
181 ,("latex" , writeLaTeX)
182 ,("latex+lhs" , \o ->
182 ,("latex+lhs" , \o ->
183 writeLaTeX o{ writerLiterateHaskell = True })
183 writeLaTeX o{ writerLiterateHaskell = True })
184+ ,("beamer" , \o ->
185+ writeLaTeX o{ writerBeamer = True })
184 ,("context" , writeConTeXt)
186 ,("context" , writeConTeXt)
185 ,("texinfo" , writeTexinfo)
187 ,("texinfo" , writeTexinfo)
186 ,("man" , writeMan)
188 ,("man" , writeMan)
src/Text/Pandoc/Shared.hs+2
@@ -477,6 +477,7 @@ data WriterOptions = WriterOptions
477 , writerCiteMethod :: CiteMethod -- ^ How to print cites
477 , writerCiteMethod :: CiteMethod -- ^ How to print cites
478 , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
478 , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
479 , writerHtml5 :: Bool -- ^ Produce HTML5
479 , writerHtml5 :: Bool -- ^ Produce HTML5
480+ , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
480 , writerChapters :: Bool -- ^ Use "chapter" for top-level sects
481 , writerChapters :: Bool -- ^ Use "chapter" for top-level sects
481 , writerListings :: Bool -- ^ Use listings package for code
482 , writerListings :: Bool -- ^ Use listings package for code
482 , writerHighlight :: Bool -- ^ Highlight source code
483 , writerHighlight :: Bool -- ^ Highlight source code
@@ -512,6 +513,7 @@ defaultWriterOptions =
512 , writerCiteMethod = Citeproc
513 , writerCiteMethod = Citeproc
513 , writerBiblioFiles = []
514 , writerBiblioFiles = []
514 , writerHtml5 = False
515 , writerHtml5 = False
516+ , writerBeamer = False
515 , writerChapters = False
517 , writerChapters = False
516 , writerListings = False
518 , writerListings = False
517 , writerHighlight = False
519 , writerHighlight = False
src/Text/Pandoc/Templates.hs+1
@@ -85,6 +85,7 @@ getDefaultTemplate _ "native" = return $ Right ""
85getDefaultTemplate _ "json" = return $ Right ""
85getDefaultTemplate _ "json" = return $ Right ""
86getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"
86getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"
87getDefaultTemplate user "epub" = getDefaultTemplate user "html"
87getDefaultTemplate user "epub" = getDefaultTemplate user "html"
88+getDefaultTemplate user "beamer" = getDefaultTemplate user "latex"
88getDefaultTemplate user writer = do
89getDefaultTemplate user writer = do
89 let format = takeWhile (/='+') writer -- strip off "+lhs" if present
90 let format = takeWhile (/='+') writer -- strip off "+lhs" if present
90 let fname = "templates" </> "default" <.> format
91 let fname = "templates" </> "default" <.> format
src/Text/Pandoc/Writers/LaTeX.hs+75−13
@@ -62,6 +62,8 @@ data WriterState =
62 , stBook :: Bool -- true if document uses book or memoir class
62 , stBook :: Bool -- true if document uses book or memoir class
63 , stCsquotes :: Bool -- true if document uses csquotes
63 , stCsquotes :: Bool -- true if document uses csquotes
64 , stHighlighting :: Bool -- true if document has highlighted code
64 , stHighlighting :: Bool -- true if document has highlighted code
65+ , stFirstFrame :: Bool -- true til we've written first beamer frame
66+ , stIncremental :: Bool -- true if beamer lists should be displayed bit by bit
65 }
67 }
66
68
67-- | Convert Pandoc to LaTeX.
69-- | Convert Pandoc to LaTeX.
@@ -74,23 +76,24 @@ writeLaTeX options document =
74 stTable = False, stStrikeout = False, stSubscript = False,
76 stTable = False, stStrikeout = False, stSubscript = False,
75 stUrl = False, stGraphics = False,
77 stUrl = False, stGraphics = False,
76 stLHS = False, stBook = writerChapters options,
78 stLHS = False, stBook = writerChapters options,
77− stCsquotes = False, stHighlighting = False }
79+ stCsquotes = False, stHighlighting = False,
80+ stFirstFrame = True, stIncremental = writerIncremental options }
78
81
79pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
82pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
80pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
83pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
81 let template = writerTemplate options
84 let template = writerTemplate options
85+ let templateLines = lines template
82 let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
86 let usesBookClass x = "\\documentclass" `isPrefixOf` x &&
83 ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
87 ("{memoir}" `isSuffixOf` x || "{book}" `isSuffixOf` x ||
84 "{report}" `isSuffixOf` x)
88 "{report}" `isSuffixOf` x)
85− when (any usesBookClass (lines template)) $
89+ when (any usesBookClass templateLines) $
86 modify $ \s -> s{stBook = True}
90 modify $ \s -> s{stBook = True}
87 -- check for \usepackage...{csquotes}; if present, we'll use
91 -- check for \usepackage...{csquotes}; if present, we'll use
88 -- \enquote{...} for smart quotes:
92 -- \enquote{...} for smart quotes:
89 when ("{csquotes}" `isInfixOf` template) $
93 when ("{csquotes}" `isInfixOf` template) $
90 modify $ \s -> s{stCsquotes = True}
94 modify $ \s -> s{stCsquotes = True}
91− opts <- liftM stOptions get
92− let colwidth = if writerWrapText opts
95+ let colwidth = if writerWrapText options
93− then Just $ writerColumns opts
96+ then Just $ writerColumns options
94 else Nothing
97 else Nothing
95 titletext <- liftM (render colwidth) $ inlineListToLaTeX title
98 titletext <- liftM (render colwidth) $ inlineListToLaTeX title
96 authorsText <- mapM (liftM (render colwidth) . inlineListToLaTeX) authors
99 authorsText <- mapM (liftM (render colwidth) . inlineListToLaTeX) authors
@@ -100,7 +103,10 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
100 else case last blocks of
103 else case last blocks of
101 Header 1 il -> (init blocks, il)
104 Header 1 il -> (init blocks, il)
102 _ -> (blocks, [])
105 _ -> (blocks, [])
106+ blocks'' <- if writerBeamer options
107+ then toSlides blocks'
108+ else return blocks'
103− body <- blockListToLaTeX blocks'
109+ body <- blockListToLaTeX blocks''
104 biblioTitle <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
110 biblioTitle <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
105 let main = render colwidth body
111 let main = render colwidth body
106 st <- get
112 st <- get
@@ -119,7 +125,12 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
119 [ ("toc", if writerTableOfContents options then "yes" else "")
125 [ ("toc", if writerTableOfContents options then "yes" else "")
120 , ("body", main)
126 , ("body", main)
121 , ("title", titletext)
127 , ("title", titletext)
122− , ("date", dateText) ] ++
128+ , ("date", dateText)
129+ , ("documentclass", if writerBeamer options
130+ then "beamer"
131+ else if writerChapters options
132+ then "book"
133+ else "article") ] ++
123 [ ("author", a) | a <- authorsText ] ++
134 [ ("author", a) | a <- authorsText ] ++
124 [ ("verbatim-in-note", "yes") | stVerbInNote st ] ++
135 [ ("verbatim-in-note", "yes") | stVerbInNote st ] ++
125 [ ("fancy-enums", "yes") | stEnumerate st ] ++
136 [ ("fancy-enums", "yes") | stEnumerate st ] ++
@@ -132,8 +143,9 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
132 [ ("graphics", "yes") | stGraphics st ] ++
143 [ ("graphics", "yes") | stGraphics st ] ++
133 [ ("book-class", "yes") | stBook st] ++
144 [ ("book-class", "yes") | stBook st] ++
134 [ ("listings", "yes") | writerListings options || stLHS st ] ++
145 [ ("listings", "yes") | writerListings options || stLHS st ] ++
146+ [ ("beamer", "yes") | writerBeamer options ] ++
135 [ ("highlighting-macros", styleToLaTeX
147 [ ("highlighting-macros", styleToLaTeX
136− $ writerHighlightStyle opts ) | stHighlighting st ] ++
148+ $ writerHighlightStyle options ) | stHighlighting st ] ++
137 citecontext
149 citecontext
138 return $ if writerStandalone options
150 return $ if writerStandalone options
139 then renderTemplate context template
151 then renderTemplate context template
@@ -171,6 +183,42 @@ stringToLaTeX isUrl = escapeStringUsing latexEscapes
171inCmd :: String -> Doc -> Doc
183inCmd :: String -> Doc -> Doc
172inCmd cmd contents = char '\\' <> text cmd <> braces contents
184inCmd cmd contents = char '\\' <> text cmd <> braces contents
173
185
186+toSlides :: [Block] -> State WriterState [Block]
187+toSlides (Header n ils : bs) = do
188+ tit <- inlineListToLaTeX ils
189+ firstFrame <- gets stFirstFrame
190+ modify $ \s -> s{ stFirstFrame = False }
191+ -- note: [fragile] is required or verbatim breaks
192+ result <- ((Header n ils :) .
193+ (RawBlock "latex" ("\\begin{frame}[fragile]\n" ++
194+ "\\frametitle{" ++ render Nothing tit ++ "}") :))
195+ `fmap` toSlides bs
196+ if firstFrame
197+ then return result
198+ else return $ RawBlock "latex" "\\end{frame}" : result
199+toSlides (HorizontalRule : Header n ils : bs) =
200+ toSlides (Header n ils : bs)
201+toSlides (HorizontalRule : bs) = do
202+ firstFrame <- gets stFirstFrame
203+ modify $ \s -> s{ stFirstFrame = False }
204+ result <- (RawBlock "latex" "\\begin{frame}[fragile]" :)
205+ `fmap` toSlides bs
206+ if firstFrame
207+ then return result
208+ else return $ RawBlock "latex" "\\end{frame}" : result
209+toSlides (b:bs) = (b:) `fmap` toSlides bs
210+toSlides [] = do
211+ firstFrame <- gets stFirstFrame
212+ if firstFrame
213+ then return []
214+ else return [RawBlock "latex" "\\end{frame}"]
215+
216+isListBlock :: Block -> Bool
217+isListBlock (BulletList _) = True
218+isListBlock (OrderedList _ _) = True
219+isListBlock (DefinitionList _) = True
220+isListBlock _ = False
221+
174-- | Convert Pandoc block element to LaTeX.
222-- | Convert Pandoc block element to LaTeX.
175blockToLaTeX :: Block -- ^ Block to convert
223blockToLaTeX :: Block -- ^ Block to convert
176 -> State WriterState Doc
224 -> State WriterState Doc
@@ -185,8 +233,17 @@ blockToLaTeX (Para lst) = do
185 result <- inlineListToLaTeX lst
233 result <- inlineListToLaTeX lst
186 return $ result <> blankline
234 return $ result <> blankline
187blockToLaTeX (BlockQuote lst) = do
235blockToLaTeX (BlockQuote lst) = do
236+ beamer <- writerBeamer `fmap` gets stOptions
237+ case lst of
238+ [b] | beamer && isListBlock b -> do
239+ oldIncremental <- gets stIncremental
240+ modify $ \s -> s{ stIncremental = True }
241+ result <- blockToLaTeX b
242+ modify $ \s -> s{ stIncremental = oldIncremental }
243+ return result
244+ _ -> do
188− contents <- blockListToLaTeX lst
245+ contents <- blockListToLaTeX lst
189− return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
246+ return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
190blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
247blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
191 opts <- gets stOptions
248 opts <- gets stOptions
192 case () of
249 case () of
@@ -243,10 +300,13 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
243blockToLaTeX (RawBlock "latex" x) = return $ text x <> blankline
300blockToLaTeX (RawBlock "latex" x) = return $ text x <> blankline
244blockToLaTeX (RawBlock _ _) = return empty
301blockToLaTeX (RawBlock _ _) = return empty
245blockToLaTeX (BulletList lst) = do
302blockToLaTeX (BulletList lst) = do
303+ incremental <- gets stIncremental
304+ let inc = if incremental then "[<+->]" else ""
246 items <- mapM listItemToLaTeX lst
305 items <- mapM listItemToLaTeX lst
247− return $ "\\begin{itemize}" $$ vcat items $$ "\\end{itemize}"
306+ return $ text ("\\begin{itemize}" ++ inc) $$ vcat items $$ "\\end{itemize}"
248blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
307blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
249 st <- get
308 st <- get
309+ let inc = if stIncremental st then "[<+->]" else ""
250 let oldlevel = stOLLevel st
310 let oldlevel = stOLLevel st
251 put $ st {stOLLevel = oldlevel + 1}
311 put $ st {stOLLevel = oldlevel + 1}
252 items <- mapM listItemToLaTeX lst
312 items <- mapM listItemToLaTeX lst
@@ -263,11 +323,13 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
263 map toLower (toRomanNumeral oldlevel) ++
323 map toLower (toRomanNumeral oldlevel) ++
264 "}{" ++ show (start - 1) ++ "}"
324 "}{" ++ show (start - 1) ++ "}"
265 else empty
325 else empty
266− return $ "\\begin{enumerate}" <> exemplar $$ resetcounter $$
326+ return $ text ("\\begin{enumerate}" ++ inc) <> exemplar $$ resetcounter $$
267 vcat items $$ "\\end{enumerate}"
327 vcat items $$ "\\end{enumerate}"
268blockToLaTeX (DefinitionList lst) = do
328blockToLaTeX (DefinitionList lst) = do
329+ incremental <- gets stIncremental
330+ let inc = if incremental then "[<+->]" else ""
269 items <- mapM defListItemToLaTeX lst
331 items <- mapM defListItemToLaTeX lst
270− return $ "\\begin{description}" $$ vcat items $$ "\\end{description}"
332+ return $ text ("\\begin{description}" ++ inc) $$ vcat items $$ "\\end{description}"
271blockToLaTeX HorizontalRule = return $
333blockToLaTeX HorizontalRule = return $
272 "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
334 "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
273blockToLaTeX (Header level lst) = do
335blockToLaTeX (Header level lst) = do
src/markdown2pdf.hs+10−6
@@ -78,11 +78,11 @@ parsePandocArgs args = do
78 --trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
78 --trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
79 trim = takeWhile (/='\r') . dropWhile (=='\r')
79 trim = takeWhile (/='\r') . dropWhile (=='\r')
80
80
81−runPandoc :: [String] -> FilePath -> IO (Either String FilePath)
81+runPandoc :: String -> [String] -> FilePath -> IO (Either String FilePath)
82−runPandoc inputsAndArgs output = do
82+runPandoc outputFormat inputsAndArgs output = do
83 let texFile = addExtension output "tex"
83 let texFile = addExtension output "tex"
84 result <- run "pandoc" $
84 result <- run "pandoc" $
85− ["-s", "--no-wrap", "-r", "markdown", "-w", "latex"]
85+ ["-s", "--no-wrap", "-r", "markdown", "-w", outputFormat]
86 ++ inputsAndArgs ++ ["-o", texFile]
86 ++ inputsAndArgs ++ ["-o", texFile]
87 return $ either Left (const $ Right texFile) result
87 return $ either Left (const $ Right texFile) result
88
88
@@ -207,14 +207,15 @@ main = withTempDir "pandoc"
207 "--custom-header","--output",
207 "--custom-header","--output",
208 "--template", "--variable",
208 "--template", "--variable",
209 "--no-highlight", "--highlight-style",
209 "--no-highlight", "--highlight-style",
210− "--csl", "--bibliography", "--data-dir", "--listings"]
210+ "--csl", "--bibliography", "--data-dir", "--listings",
211+ "--beamer"]
211 let isOpt ('-':_) = True
212 let isOpt ('-':_) = True
212 isOpt _ = False
213 isOpt _ = False
213 let opts = filter isOpt args
214 let opts = filter isOpt args
214 -- note that a long option can come in this form: --opt=val
215 -- note that a long option can come in this form: --opt=val
215 let isGoodopt x = x `elem` (goodopts ++ goodoptslong) ||
216 let isGoodopt x = x `elem` (goodopts ++ goodoptslong) ||
216 any (\o -> (o ++ "=") `isPrefixOf` x) goodoptslong
217 any (\o -> (o ++ "=") `isPrefixOf` x) goodoptslong
217− let markdown2pdfOpts = ["--xetex","--luatex"]
218+ let markdown2pdfOpts = ["--xetex","--luatex", "--beamer"]
218 unless (all isGoodopt opts) $ do
219 unless (all isGoodopt opts) $ do
219 (code, out, _err) <- readProcessWithExitCode "pandoc" ["--help"] ""
220 (code, out, _err) <- readProcessWithExitCode "pandoc" ["--help"] ""
220 UTF8.putStrLn "markdown2pdf [OPTIONS] [FILES]\nOptions:"
221 UTF8.putStrLn "markdown2pdf [OPTIONS] [FILES]\nOptions:"
@@ -231,6 +232,9 @@ main = withTempDir "pandoc"
231 else if "--luatex" `elem` opts
232 else if "--luatex" `elem` opts
232 then "lualatex"
233 then "lualatex"
233 else "pdflatex"
234 else "pdflatex"
235+ let outputFormat = if "--beamer" `elem` opts
236+ then "beamer"
237+ else "latex"
234 let execs = ["pandoc", latexProgram, "bibtex"]
238 let execs = ["pandoc", latexProgram, "bibtex"]
235 paths <- mapM findExecutable execs
239 paths <- mapM findExecutable execs
236 let miss = map snd $ filter (isNothing . fst) $ zip paths execs
240 let miss = map snd $ filter (isNothing . fst) $ zip paths execs
@@ -249,7 +253,7 @@ main = withTempDir "pandoc"
249 -- no need because we'll pass all arguments to pandoc
253 -- no need because we'll pass all arguments to pandoc
250 Just (_ ,out) -> return ([], out)
254 Just (_ ,out) -> return ([], out)
251 -- run pandoc
255 -- run pandoc
252− pandocRes <- runPandoc (input ++ args') $ replaceDirectory output tmp
256+ pandocRes <- runPandoc outputFormat (input ++ args') $ replaceDirectory output tmp
253 case pandocRes of
257 case pandocRes of
254 Left err -> exit err
258 Left err -> exit err
255 Right texFile -> do
259 Right texFile -> do
templates+1−1

Submodule changed.

tests/lhs-test.latex+1−1
@@ -1,4 +1,4 @@
1−\documentclass{article}
1+\documentclass[]{article}
2\usepackage{amssymb,amsmath}
2\usepackage{amssymb,amsmath}
3\usepackage{ifxetex,ifluatex}
3\usepackage{ifxetex,ifluatex}
4\ifxetex
4\ifxetex
tests/lhs-test.latex+lhs+1−1
@@ -1,4 +1,4 @@
1−\documentclass{article}
1+\documentclass[]{article}
2\usepackage{amssymb,amsmath}
2\usepackage{amssymb,amsmath}
3\usepackage{ifxetex,ifluatex}
3\usepackage{ifxetex,ifluatex}
4\ifxetex
4\ifxetex
tests/writer.latex+1−1
@@ -1,4 +1,4 @@
1−\documentclass{article}
1+\documentclass[]{article}
2\usepackage{amssymb,amsmath}
2\usepackage{amssymb,amsmath}
3\usepackage{ifxetex,ifluatex}
3\usepackage{ifxetex,ifluatex}
4\ifxetex
4\ifxetex