diff options
Diffstat (limited to 'Text/Pandoc/Writers')
-rw-r--r-- | Text/Pandoc/Writers/HTML.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 6ada56ba2..bcf39ef9f 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -273,10 +273,14 @@ blockToHtml opts (RawHtml str) = return $ primHtml str blockToHtml opts (HorizontalRule) = return $ hr blockToHtml opts (CodeBlock attr@(_,classes,_) rawCode) = do case highlightHtml attr rawCode of - Left _ -> return $ pre ! (if null classes - then [] - else [theclass $ unwords classes]) $ thecode << - (rawCode ++ "\n") + Left _ -> -- change leading newlines into <br /> tags, because some + -- browsers ignore leading newlines in pre blocks + let (leadingBreaks, rawCode') = span (=='\n') rawCode + in return $ pre ! (if null classes + then [] + else [theclass $ unwords classes]) $ thecode << + (replicate (length leadingBreaks) br +++ + [stringToHtml $ rawCode' ++ "\n"]) Right h -> addToCSS defaultHighlightingCss >> return h blockToHtml opts (BlockQuote blocks) = -- in S5, treat list in blockquote specially |