diff options
Diffstat (limited to 'Text/Pandoc')
-rw-r--r-- | Text/Pandoc/Writers/HTML.hs | 4 | ||||
-rw-r--r-- | Text/Pandoc/Writers/LaTeX.hs | 12 | ||||
-rw-r--r-- | Text/Pandoc/Writers/Markdown.hs | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 8dafd2440..087fff623 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -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 diff --git a/Text/Pandoc/Writers/LaTeX.hs b/Text/Pandoc/Writers/LaTeX.hs index dd0e23981..f3cbf1acb 100644 --- a/Text/Pandoc/Writers/LaTeX.hs +++ b/Text/Pandoc/Writers/LaTeX.hs @@ -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 diff --git a/Text/Pandoc/Writers/Markdown.hs b/Text/Pandoc/Writers/Markdown.hs index 32ebcf758..4b365773f 100644 --- a/Text/Pandoc/Writers/Markdown.hs +++ b/Text/Pandoc/Writers/Markdown.hs @@ -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 |