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
This commit is contained in:
fiddlosopher 2008-12-02 22:42:46 +00:00
parent 9aecc17c1d
commit 6359c789a7

View file

@ -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"