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
This commit is contained in:
fiddlosopher 2008-12-02 22:42:29 +00:00
parent 48410d1df0
commit 430e55c0f1
5 changed files with 42 additions and 5 deletions

14
README
View file

@ -371,6 +371,20 @@ For further documentation, see the `pandoc(1)` man page.
are omitted. URIs in links and images are also checked against a
whitelist of URI schemes.
`--lhs-in`
: treat input as literate Haskell. In markdown input, "bird track"
sections will be treated as Haskell source code. In LaTeX input,
`code` environments will be treated as Haskell source code.
`--lhs-out`
: write output as literate Haskell. In markdown output, Haskell
source code will be printed with "bird tracks." In LaTeX output,
it will be put in `code` environments. In HTML output, it will
be put inside `<pre>` tags, with "bird tracks."
`--lhs`
: equivalent to `--lhs-in --lhs-out`.
`--dump-args`
: is intended to make it easier to create wrapper scripts that use
Pandoc. It causes Pandoc to dump information about the arguments

View file

@ -297,6 +297,10 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
blockToHtml _ (RawHtml str) = return $ primHtml str
blockToHtml _ (HorizontalRule) = return $ hr
blockToHtml opts (CodeBlock (_,classes,_) rawCode) | "haskell" `elem` classes &&
writerLiterateHaskell opts =
let classes' = map (\c -> if c == "haskell" then "literatehaskell" else c) classes
in blockToHtml opts $ CodeBlock ("",classes',[]) $ intercalate "\n" $ map ("> " ++) $ lines rawCode
blockToHtml _ (CodeBlock attr@(_,classes,_) rawCode) = do
case highlightHtml attr rawCode of
Left _ -> -- change leading newlines into <br /> tags, because some

View file

@ -147,12 +147,14 @@ blockToLaTeX (Para lst) = do
blockToLaTeX (BlockQuote lst) = do
contents <- blockListToLaTeX lst
return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
blockToLaTeX (CodeBlock _ str) = do
blockToLaTeX (CodeBlock (_,classes,_) str) = do
st <- get
env <- if stInNote st
then do addToHeader "\\usepackage{fancyvrb}"
return "Verbatim"
else return "verbatim"
env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes
then return "code"
else if stInNote st
then do addToHeader "\\usepackage{fancyvrb}"
return "Verbatim"
else return "verbatim"
return $ text ("\\begin{" ++ env ++ "}\n") <> text str <>
text ("\n\\end{" ++ env ++ "}")
blockToLaTeX (RawHtml _) = return empty

View file

@ -185,6 +185,9 @@ blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
blockToMarkdown opts (Header level inlines) = do
contents <- inlineListToMarkdown opts inlines
return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
blockToMarkdown opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes &&
writerLiterateHaskell opts =
return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
blockToMarkdown opts (CodeBlock _ str) = return $
(nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
blockToMarkdown opts (BlockQuote blocks) = do

View file

@ -142,6 +142,20 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
are omitted. URIs in links and images are also checked against a
whitelist of URI schemes.
\--lhs-in
: Treat input as literate Haskell. In markdown input, "bird track"
sections will be treated as Haskell source code. In LaTeX input,
`code` environments will be treated as Haskell source code.
\--lhs-out
: Write output as literate Haskell. In markdown output, Haskell
source code will be printed with "bird tracks." In LaTeX output,
it will be put in `code` environments. In HTML output, it will
be put inside `<pre>` tags, with "bird tracks."
\--lhs
: Equivalent to `--lhs-in --lhs-out`.
\--toc, \--table-of-contents
: Include an automatically generated table of contents (HTML, markdown,
RTF) or an instruction to create one (LaTeX, reStructuredText).