From 6cff8dfc8af7a20afe8b307e29c010db7b6053d8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 26 Aug 2025 18:57:14 +0200 Subject: HTML reader: don't drop the initial newline in a pre element. Closes #11064. --- src/Text/Pandoc/Readers/HTML.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index fcc1147ca..3c8c9d50b 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -659,14 +659,10 @@ pCodeBlock = try $ do else v ] contents <- manyTill pAny (pCloses "pre" <|> eof) let rawText = T.concat $ map tagToText contents - -- drop leading newline if any - let result' = case T.uncons rawText of - Just ('\n', xs) -> xs - _ -> rawText -- drop trailing newline if any - let result = case T.unsnoc result' of + let result = case T.unsnoc rawText of Just (result'', '\n') -> result'' - _ -> result' + _ -> rawText return $ B.codeBlockWith attr result tagToText :: Tag Text -> Text -- cgit v1.2.3