Markdown writer: Use setext headers for levels 1-2.

This commit is contained in:
John MacFarlane 2011-11-24 11:14:32 -08:00
parent 1b6d0f2e1d
commit ce40d0d0c2

View file

@ -233,17 +233,15 @@ blockToMarkdown _ HorizontalRule =
blockToMarkdown opts (Header level inlines) = do
contents <- inlineListToMarkdown opts inlines
st <- get
-- use setext style headers if in literate haskell mode.
-- ghc interprets '#' characters in column 1 as line number specifiers.
if writerLiterateHaskell opts || stPlain st
then let len = offset contents
in return $ contents <> cr <>
(case level of
1 -> text $ replicate len '='
2 -> text $ replicate len '-'
_ -> empty) <> blankline
else return $
text ((replicate level '#') ++ " ") <> contents <> blankline
return $ case level of
1 -> contents <> cr <> text (replicate (offset contents) '=') <>
blankline
2 -> contents <> cr <> text (replicate (offset contents) '-') <>
blankline
-- ghc interprets '#' characters in column 1 as linenum specifiers.
_ | stPlain st || writerLiterateHaskell opts ->
contents <> blankline
_ -> text (replicate level '#') <> space <> contents <> blankline
blockToMarkdown opts (CodeBlock (_,classes,_) str)
| "haskell" `elem` classes && "literate" `elem` classes &&
writerLiterateHaskell opts =