git.iko.soy/typeable/pandoc
on master help sign in
Handle --lhs-out option in HTML, LaTeX, and Markdown writers.

Documented lhs options in man page and README. Note: HTML output with --lhs-out is not strictly literate haskell, but it is designed so that the result of copying and pasting the page in the browser will be a literate haskell file. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1501 788f1e2b-df1e-0410-8736-df70ead52e1b

commit430e55c0f1ca94fdb20b99061862af2ceabe4469 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 2 Dec 2008, 22:42 (18 years ago) parent48410d1
5 files changed+42−5
README+14 Text/Pandoc/Writers/HTML.hs+4 Text/Pandoc/Writers/LaTeX.hs+7−5 Text/Pandoc/Writers/Markdown.hs+3 man/man1/pandoc.1.md+14
README+14
@@ -371,6 +371,20 @@ For further documentation, see the `pandoc(1)` man page.
371371 are omitted. URIs in links and images are also checked against a
372372 whitelist of URI schemes.
373373
374+`--lhs-in`
375+: treat input as literate Haskell. In markdown input, "bird track"
376+ sections will be treated as Haskell source code. In LaTeX input,
377+ `code` environments will be treated as Haskell source code.
378+
379+`--lhs-out`
380+: write output as literate Haskell. In markdown output, Haskell
381+ source code will be printed with "bird tracks." In LaTeX output,
382+ it will be put in `code` environments. In HTML output, it will
383+ be put inside `<pre>` tags, with "bird tracks."
384+
385+`--lhs`
386+: equivalent to `--lhs-in --lhs-out`.
387+
374388`--dump-args`
375389: is intended to make it easier to create wrapper scripts that use
376390 Pandoc. It causes Pandoc to dump information about the arguments
Text/Pandoc/Writers/HTML.hs+4
@@ -297,6 +297,10 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
297297blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
298298blockToHtml _ (RawHtml str) = return $ primHtml str
299299blockToHtml _ (HorizontalRule) = return $ hr
300+blockToHtml opts (CodeBlock (_,classes,_) rawCode) | "haskell" `elem` classes &&
301+ writerLiterateHaskell opts =
302+ let classes' = map (\c -> if c == "haskell" then "literatehaskell" else c) classes
303+ in blockToHtml opts $ CodeBlock ("",classes',[]) $ intercalate "\n" $ map ("> " ++) $ lines rawCode
300304blockToHtml _ (CodeBlock attr@(_,classes,_) rawCode) = do
301305 case highlightHtml attr rawCode of
302306 Left _ -> -- change leading newlines into <br /> tags, because some
Text/Pandoc/Writers/LaTeX.hs+7−5
@@ -147,12 +147,14 @@ blockToLaTeX (Para lst) = do
147147blockToLaTeX (BlockQuote lst) = do
148148 contents <- blockListToLaTeX lst
149149 return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
150−blockToLaTeX (CodeBlock _ str) = do
150+blockToLaTeX (CodeBlock (_,classes,_) str) = do
151151 st <- get
152− env <- if stInNote st
153− then do addToHeader "\\usepackage{fancyvrb}"
154− return "Verbatim"
155− else return "verbatim"
152+ env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes
153+ then return "code"
154+ else if stInNote st
155+ then do addToHeader "\\usepackage{fancyvrb}"
156+ return "Verbatim"
157+ else return "verbatim"
156158 return $ text ("\\begin{" ++ env ++ "}\n") <> text str <>
157159 text ("\n\\end{" ++ env ++ "}")
158160blockToLaTeX (RawHtml _) = return empty
Text/Pandoc/Writers/Markdown.hs+3
@@ -185,6 +185,9 @@ blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
185185blockToMarkdown opts (Header level inlines) = do
186186 contents <- inlineListToMarkdown opts inlines
187187 return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
188+blockToMarkdown opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes &&
189+ writerLiterateHaskell opts =
190+ return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
188191blockToMarkdown opts (CodeBlock _ str) = return $
189192 (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
190193blockToMarkdown opts (BlockQuote blocks) = do
man/man1/pandoc.1.md+14
@@ -142,6 +142,20 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
142142 are omitted. URIs in links and images are also checked against a
143143 whitelist of URI schemes.
144144
145+\--lhs-in
146+: Treat input as literate Haskell. In markdown input, "bird track"
147+ sections will be treated as Haskell source code. In LaTeX input,
148+ `code` environments will be treated as Haskell source code.
149+
150+\--lhs-out
151+: Write output as literate Haskell. In markdown output, Haskell
152+ source code will be printed with "bird tracks." In LaTeX output,
153+ it will be put in `code` environments. In HTML output, it will
154+ be put inside `<pre>` tags, with "bird tracks."
155+
156+\--lhs
157+: Equivalent to `--lhs-in --lhs-out`.
158+
145159\--toc, \--table-of-contents
146160: Include an automatically generated table of contents (HTML, markdown,
147161 RTF) or an instruction to create one (LaTeX, reStructuredText).