From 9766b532f38266d0606520fcbfb0c13fd5b09a2f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 9 Mar 2012 10:32:32 -0800 Subject: Added beamer+lhs as output format. --- README | 11 ++++++----- src/Text/Pandoc.hs | 2 ++ src/pandoc.hs | 30 ++++++++++++++---------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README b/README index 23fde19c2..f32596af2 100644 --- a/README +++ b/README @@ -138,7 +138,7 @@ General options `json` (JSON version of native AST), `markdown` (markdown), `textile` (Textile), `rst` (reStructuredText), `html` (HTML), or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`, - or `latex`, the input will be treated as literate Haskell source: + `latex`, the input will be treated as literate Haskell source: see [Literate Haskell support](#literate-haskell-support), below. @@ -156,8 +156,8 @@ General options slide show), or `rtf` (rich text format). Note that `odt` and `epub` output will not be directed to *stdout*; an output filename must be specified using the `-o/--output` option. If `+lhs` is appended - to `markdown`, `rst`, `latex`, `html`, or `html5`, the output will - be rendered as literate Haskell source: see [Literate Haskell + to `markdown`, `rst`, `latex`, `beamer`, `html`, or `html5`, the output + will be rendered as literate Haskell source: see [Literate Haskell support](#literate-haskell-support), below. `-o` *FILE*, `--output=`*FILE* @@ -2168,8 +2168,9 @@ Literate Haskell support ======================== If you append `+lhs` to an appropriate input or output format (`markdown`, -`rst`, or `latex` for input or output; `html` or `html5` for output only), -pandoc will treat the document as literate Haskell source. This means that +`rst`, or `latex` for input or output; `beamer`, `html` or `html5` for +output only), pandoc will treat the document as literate Haskell source. +This means that - In markdown input, "bird track" sections will be parsed as Haskell code rather than block quotations. Text between `\begin{code}` diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 878f0e0dd..597d2e07f 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -192,6 +192,8 @@ writers = [("native" , writeNative) writeLaTeX o{ writerLiterateHaskell = True }) ,("beamer" , \o -> writeLaTeX o{ writerBeamer = True }) + ,("beamer+lhs" , \o -> + writeLaTeX o{ writerBeamer = True, writerLiterateHaskell = True }) ,("context" , writeConTeXt) ,("texinfo" , writeTexinfo) ,("man" , writeMan) diff --git a/src/pandoc.hs b/src/pandoc.hs index 3853d360a..be65c8856 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -833,10 +833,12 @@ main = do let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" + let laTeXOutput = writerName' == "latex" || writerName' == "beamer" || + writerName' == "latex+lhs" || writerName' == "beamer+lhs" + when pdfOutput $ do -- make sure writer is latex or beamer - unless (writerName' == "latex" || writerName' == "beamer" || - writerName' == "latex+lhs") $ + unless laTeXOutput $ err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer" -- check for latex program mbLatex <- findExecutable latexEngine @@ -916,14 +918,13 @@ main = do lhsExtension sources, stateStandalone = standalone', stateCitations = map CSL.refId refs, - stateSmart = smart || writerName' `elem` - ["latex", "context", "latex+lhs", "beamer"], + stateSmart = smart || laTeXOutput || writerName' == "context", stateOldDashes = oldDashes, stateColumns = columns, stateStrict = strict, stateIndentedCodeClasses = codeBlockClasses, - stateApplyMacros = writerName' `notElem` - ["latex", "latex+lhs", "beamer"] } + stateApplyMacros = not laTeXOutput + } let writerOptions = defaultWriterOptions { writerStandalone = standalone', @@ -945,8 +946,7 @@ main = do writerReferenceLinks = referenceLinks, writerWrapText = wrap, writerColumns = columns, - writerLiterateHaskell = "+lhs" `isSuffixOf` writerName' || - lhsExtension [outputFile], + writerLiterateHaskell = False, writerEmailObfuscation = if strict then ReferenceObfuscation else obfuscationMethod, @@ -957,7 +957,7 @@ main = do slideVariant == DZSlides, writerChapters = chapters, writerListings = listings, - writerBeamer = writerName' == "beamer", + writerBeamer = False, writerSlideLevel = slideLevel, writerHighlight = highlight, writerHighlightStyle = highlightStyle, @@ -980,9 +980,7 @@ main = do let convertTabs = tabFilter (if preserveTabs then 0 else tabStop) - let handleIncludes' = if readerName' == "latex" || readerName' == "beamer" || - readerName' == "latex+lhs" || - readerName' == "context" + let handleIncludes' = if readerName' == "latex" || readerName' == "latex+lhs" then handleIncludes else return @@ -1029,18 +1027,18 @@ main = do | writerName' == "docx" -> writeDocx referenceDocx writerOptions doc2 >>= writeBinary | otherwise -> err 9 ("Unknown writer: " ++ writerName') - Just _ + Just w | pdfOutput -> do - res <- tex2pdf latexEngine $ writeLaTeX writerOptions doc2 + res <- tex2pdf latexEngine $ w writerOptions doc2 case res of Right pdf -> writeBinary pdf Left err' -> err 43 $ toString err' - Just r + Just w | htmlFormat && ascii -> writerFn outputFile =<< selfcontain (toEntities result) | otherwise -> writerFn outputFile =<< selfcontain result - where result = r writerOptions doc2 ++ ['\n' | not standalone'] + where result = w writerOptions doc2 ++ ['\n' | not standalone'] htmlFormat = writerName' `elem` ["html","html+lhs","html5","html5+lhs", "s5","slidy","dzslides"] -- cgit v1.2.3