aboutsummaryrefslogtreecommitdiff
path: root/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-05-15 00:54:33 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-05-15 00:54:33 +0000
commit69c2bde7d999e689f89aee2203ad1923c7a24037 (patch)
tree3a137c3d786251cfbf793c5827e7efc79d281ec5 /Text/Pandoc/Writers
parent6a46ffc0ad3d3ef5c4426d0e726f40dda1bfaf38 (diff)
downloadpandoc-69c2bde7d999e689f89aee2203ad1923c7a24037.tar.gz
HTML writer: In code blocks, change leading newlines to <br /> 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
Diffstat (limited to 'Text/Pandoc/Writers')
-rw-r--r--Text/Pandoc/Writers/HTML.hs12
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