From 69c2bde7d999e689f89aee2203ad1923c7a24037 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 15 May 2008 00:54:33 +0000 Subject: HTML writer: In code blocks, change leading newlines to
tags. (Some browsers ignore them.) Resolves Issue #71. See http://six.pairlist.net/pipermail/markdown-discuss/2008-May/001297.html git-svn-id: https://pandoc.googlecode.com/svn/trunk@1277 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Writers/HTML.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Text/Pandoc/Writers') 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
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 -- cgit v1.2.3