git.iko.soy/typeable/pandoc
on master help sign in
Handle --lhs-out option in HTML, LaTeX, and Markdown writers.
430e55cfiddlosopher
@@ -371,6 +371,20 @@ For further documentation, see the `pandoc(1)` man page.
371 are omitted. URIs in links and images are also checked against a
371 are omitted. URIs in links and images are also checked against a
372 whitelist of URI schemes.
372 whitelist of URI schemes.
373
373
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+
374`--dump-args`
388`--dump-args`
375: is intended to make it easier to create wrapper scripts that use
389: is intended to make it easier to create wrapper scripts that use
376 Pandoc. It causes Pandoc to dump information about the arguments
390 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
297blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
297blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
298blockToHtml _ (RawHtml str) = return $ primHtml str
298blockToHtml _ (RawHtml str) = return $ primHtml str
299blockToHtml _ (HorizontalRule) = return $ hr
299blockToHtml _ (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
300blockToHtml _ (CodeBlock attr@(_,classes,_) rawCode) = do
304blockToHtml _ (CodeBlock attr@(_,classes,_) rawCode) = do
301 case highlightHtml attr rawCode of
305 case highlightHtml attr rawCode of
302 Left _ -> -- change leading newlines into <br /> tags, because some
306 Left _ -> -- change leading newlines into <br /> tags, because some
Text/Pandoc/Writers/LaTeX.hs+7−5
@@ -147,12 +147,14 @@ blockToLaTeX (Para lst) = do
147blockToLaTeX (BlockQuote lst) = do
147blockToLaTeX (BlockQuote lst) = do
148 contents <- blockListToLaTeX lst
148 contents <- blockListToLaTeX lst
149 return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
149 return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
150−blockToLaTeX (CodeBlock _ str) = do
150+blockToLaTeX (CodeBlock (_,classes,_) str) = do
151 st <- get
151 st <- get
152+ env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes
153+ then return "code"
152− env <- if stInNote st
154+ else if stInNote st
153− then do addToHeader "\\usepackage{fancyvrb}"
155+ then do addToHeader "\\usepackage{fancyvrb}"
154− return "Verbatim"
156+ return "Verbatim"
155− else return "verbatim"
157+ else return "verbatim"
156 return $ text ("\\begin{" ++ env ++ "}\n") <> text str <>
158 return $ text ("\\begin{" ++ env ++ "}\n") <> text str <>
157 text ("\n\\end{" ++ env ++ "}")
159 text ("\n\\end{" ++ env ++ "}")
158blockToLaTeX (RawHtml _) = return empty
160blockToLaTeX (RawHtml _) = return empty
Text/Pandoc/Writers/Markdown.hs+3
@@ -185,6 +185,9 @@ blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
185blockToMarkdown opts (Header level inlines) = do
185blockToMarkdown opts (Header level inlines) = do
186 contents <- inlineListToMarkdown opts inlines
186 contents <- inlineListToMarkdown opts inlines
187 return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
187 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"
188blockToMarkdown opts (CodeBlock _ str) = return $
191blockToMarkdown opts (CodeBlock _ str) = return $
189 (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
192 (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
190blockToMarkdown opts (BlockQuote blocks) = do
193blockToMarkdown opts (BlockQuote blocks) = do
man/man1/pandoc.1.md+14
@@ -142,6 +142,20 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
142 are omitted. URIs in links and images are also checked against a
142 are omitted. URIs in links and images are also checked against a
143 whitelist of URI schemes.
143 whitelist of URI schemes.
144
144
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+
145\--toc, \--table-of-contents
159\--toc, \--table-of-contents
146: Include an automatically generated table of contents (HTML, markdown,
160: Include an automatically generated table of contents (HTML, markdown,
147 RTF) or an instruction to create one (LaTeX, reStructuredText).
161 RTF) or an instruction to create one (LaTeX, reStructuredText).