aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-12-02 22:42:46 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-12-02 22:42:46 +0000
commit6359c789a76a455ae54d9b13537caf31d043161f (patch)
treeec15684d51e03a44f59c907d25b4d0bd5fcc4309
parent9aecc17c1d411a4cd5474dfd88968d06111f7811 (diff)
downloadpandoc-6359c789a76a455ae54d9b13537caf31d043161f.tar.gz
Markdown writer: Use setext style headers only if --lhs-out specified.
Reason: ghc doesn't like '#' characters in lhs comment sections. See http://www.haskell.org/pipermail/haskell-cafe/2008-December/051300.html git-svn-id: https://pandoc.googlecode.com/svn/trunk@1503 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r--Text/Pandoc/Writers/Markdown.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/Text/Pandoc/Writers/Markdown.hs b/Text/Pandoc/Writers/Markdown.hs
index 2b4ae8d0a..787700603 100644
--- a/Text/Pandoc/Writers/Markdown.hs
+++ b/Text/Pandoc/Writers/Markdown.hs
@@ -184,7 +184,16 @@ blockToMarkdown _ (RawHtml str) = return $ text str
blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
blockToMarkdown opts (Header level inlines) = do
contents <- inlineListToMarkdown opts inlines
- return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
+ -- use setext style headers if in literate haskell mode.
+ -- ghc interprets '#' characters in column 1 as line number specifiers.
+ if writerLiterateHaskell opts
+ then let len = length $ render contents
+ in return $ contents <> text "\n" <>
+ case level of
+ 1 -> text $ replicate len '=' ++ "\n"
+ 2 -> text $ replicate len '-' ++ "\n"
+ _ -> empty
+ else 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"