aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2011-11-24 11:14:32 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2011-11-24 11:14:32 -0800
commitce40d0d0c2a69e6e8fc000099255bf73698c33bb (patch)
tree7152dce0e9c716b9764e5710a4383ee16299591f /src
parent1b6d0f2e1d0aca0e0684629e1d36792552190575 (diff)
downloadpandoc-ce40d0d0c2a69e6e8fc000099255bf73698c33bb.tar.gz
Markdown writer: Use setext headers for levels 1-2.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs20
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 =