aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 =