git.iko.soy/typeable/pandoc
on master help sign in
Added beamer+lhs as output format.
commit9766b532f38266d0606520fcbfb0c13fd5b09a2f authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 9 Mar 2012, 10:32 (15 years ago) parent6787cf2
3 files changed+22−21
README+6−5 src/Text/Pandoc.hs+2 src/pandoc.hs+14−16
README+6−5
@@ -138,7 +138,7 @@ General options
138138 `json` (JSON version of native AST), `markdown` (markdown),
139139 `textile` (Textile), `rst` (reStructuredText), `html` (HTML),
140140 or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
141− or `latex`, the input will be treated as literate Haskell source:
141+ `latex`, the input will be treated as literate Haskell source:
142142 see [Literate Haskell support](#literate-haskell-support),
143143 below.
144144
@@ -156,8 +156,8 @@ General options
156156 slide show), or `rtf` (rich text format). Note that `odt` and `epub`
157157 output will not be directed to *stdout*; an output filename must
158158 be specified using the `-o/--output` option. If `+lhs` is appended
159− to `markdown`, `rst`, `latex`, `html`, or `html5`, the output will
160− be rendered as literate Haskell source: see [Literate Haskell
159+ to `markdown`, `rst`, `latex`, `beamer`, `html`, or `html5`, the output
160+ will be rendered as literate Haskell source: see [Literate Haskell
161161 support](#literate-haskell-support), below.
162162
163163`-o` *FILE*, `--output=`*FILE*
@@ -2168,8 +2168,9 @@ Literate Haskell support
21682168========================
21692169
21702170If you append `+lhs` to an appropriate input or output format (`markdown`,
2171−`rst`, or `latex` for input or output; `html` or `html5` for output only),
2172−pandoc will treat the document as literate Haskell source. This means that
2171+`rst`, or `latex` for input or output; `beamer`, `html` or `html5` for
2172+output only), pandoc will treat the document as literate Haskell source.
2173+This means that
21732174
21742175 - In markdown input, "bird track" sections will be parsed as Haskell
21752176 code rather than block quotations. Text between `\begin{code}`
src/Text/Pandoc.hs+2
@@ -192,6 +192,8 @@ writers = [("native" , writeNative)
192192 writeLaTeX o{ writerLiterateHaskell = True })
193193 ,("beamer" , \o ->
194194 writeLaTeX o{ writerBeamer = True })
195+ ,("beamer+lhs" , \o ->
196+ writeLaTeX o{ writerBeamer = True, writerLiterateHaskell = True })
195197 ,("context" , writeConTeXt)
196198 ,("texinfo" , writeTexinfo)
197199 ,("man" , writeMan)
src/pandoc.hs+14−16
@@ -833,10 +833,12 @@ main = do
833833
834834 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
835835
836+ let laTeXOutput = writerName' == "latex" || writerName' == "beamer" ||
837+ writerName' == "latex+lhs" || writerName' == "beamer+lhs"
838+
836839 when pdfOutput $ do
837840 -- make sure writer is latex or beamer
838− unless (writerName' == "latex" || writerName' == "beamer" ||
839− writerName' == "latex+lhs") $
841+ unless laTeXOutput $
840842 err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"
841843 -- check for latex program
842844 mbLatex <- findExecutable latexEngine
@@ -916,14 +918,13 @@ main = do
916918 lhsExtension sources,
917919 stateStandalone = standalone',
918920 stateCitations = map CSL.refId refs,
919− stateSmart = smart || writerName' `elem`
920− ["latex", "context", "latex+lhs", "beamer"],
921+ stateSmart = smart || laTeXOutput || writerName' == "context",
921922 stateOldDashes = oldDashes,
922923 stateColumns = columns,
923924 stateStrict = strict,
924925 stateIndentedCodeClasses = codeBlockClasses,
925− stateApplyMacros = writerName' `notElem`
926− ["latex", "latex+lhs", "beamer"] }
926+ stateApplyMacros = not laTeXOutput
927+ }
927928
928929 let writerOptions = defaultWriterOptions
929930 { writerStandalone = standalone',
@@ -945,8 +946,7 @@ main = do
945946 writerReferenceLinks = referenceLinks,
946947 writerWrapText = wrap,
947948 writerColumns = columns,
948− writerLiterateHaskell = "+lhs" `isSuffixOf` writerName' ||
949− lhsExtension [outputFile],
949+ writerLiterateHaskell = False,
950950 writerEmailObfuscation = if strict
951951 then ReferenceObfuscation
952952 else obfuscationMethod,
@@ -957,7 +957,7 @@ main = do
957957 slideVariant == DZSlides,
958958 writerChapters = chapters,
959959 writerListings = listings,
960− writerBeamer = writerName' == "beamer",
960+ writerBeamer = False,
961961 writerSlideLevel = slideLevel,
962962 writerHighlight = highlight,
963963 writerHighlightStyle = highlightStyle,
@@ -980,9 +980,7 @@ main = do
980980
981981 let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
982982
983− let handleIncludes' = if readerName' == "latex" || readerName' == "beamer" ||
984− readerName' == "latex+lhs" ||
985− readerName' == "context"
983+ let handleIncludes' = if readerName' == "latex" || readerName' == "latex+lhs"
986984 then handleIncludes
987985 else return
988986
@@ -1029,18 +1027,18 @@ main = do
10291027 | writerName' == "docx" ->
10301028 writeDocx referenceDocx writerOptions doc2 >>= writeBinary
10311029 | otherwise -> err 9 ("Unknown writer: " ++ writerName')
1032− Just _
1030+ Just w
10331031 | pdfOutput -> do
1034− res <- tex2pdf latexEngine $ writeLaTeX writerOptions doc2
1032+ res <- tex2pdf latexEngine $ w writerOptions doc2
10351033 case res of
10361034 Right pdf -> writeBinary pdf
10371035 Left err' -> err 43 $ toString err'
1038− Just r
1036+ Just w
10391037 | htmlFormat && ascii ->
10401038 writerFn outputFile =<< selfcontain (toEntities result)
10411039 | otherwise ->
10421040 writerFn outputFile =<< selfcontain result
1043− where result = r writerOptions doc2 ++ ['\n' | not standalone']
1041+ where result = w writerOptions doc2 ++ ['\n' | not standalone']
10441042 htmlFormat = writerName' `elem`
10451043 ["html","html+lhs","html5","html5+lhs",
10461044 "s5","slidy","dzslides"]