@@ -273,10 +273,14 @@ blockToHtml opts (RawHtml str) = return $ primHtml str
273273blockToHtml opts (HorizontalRule) = return $ hr
274274blockToHtml opts (CodeBlock attr@(_,classes,_) rawCode) = do
275275 case highlightHtml attr rawCode of
276− Left _ -> return $ pre ! (if null classes
277− then []
278− else [theclass $ unwords classes]) $ thecode <<
279− (rawCode ++ "\n")
276+ Left _ -> -- change leading newlines into <br /> tags, because some
277+ -- browsers ignore leading newlines in pre blocks
278+ let (leadingBreaks, rawCode') = span (=='\n') rawCode
279+ in return $ pre ! (if null classes
280+ then []
281+ else [theclass $ unwords classes]) $ thecode <<
282+ (replicate (length leadingBreaks) br +++
283+ [stringToHtml $ rawCode' ++ "\n"])
280284 Right h -> addToCSS defaultHighlightingCss >> return h
281285blockToHtml opts (BlockQuote blocks) =
282286 -- in S5, treat list in blockquote specially