diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-11-24 11:14:32 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-11-24 11:14:32 -0800 |
commit | ce40d0d0c2a69e6e8fc000099255bf73698c33bb (patch) | |
tree | 7152dce0e9c716b9764e5710a4383ee16299591f /src | |
parent | 1b6d0f2e1d0aca0e0684629e1d36792552190575 (diff) | |
download | pandoc-ce40d0d0c2a69e6e8fc000099255bf73698c33bb.tar.gz |
Markdown writer: Use setext headers for levels 1-2.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 48e9578b4..42a59cc5f 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -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 = |