diff options
| -rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 8 | ||||
| -rw-r--r-- | test/Tests/Readers/HTML.hs | 4 |
2 files changed, 4 insertions, 8 deletions
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 diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs index 5b7ab12fd..7c075de0b 100644 --- a/test/Tests/Readers/HTML.hs +++ b/test/Tests/Readers/HTML.hs @@ -130,10 +130,10 @@ tests = [ testGroup "base tag" [ test html "attributes in pre > code element" $ "<pre><code id=\"a\" class=\"python\">\nprint('hi')\n</code></pre>" =?> - codeBlockWith ("a", ["python"], []) "print('hi')" + codeBlockWith ("a", ["python"], []) "\nprint('hi')" , test html "attributes in pre take precedence" $ - "<pre id=\"c\"><code id=\"d\">\nprint('hi mom!')\n</code></pre>" + "<pre id=\"c\"><code id=\"d\">print('hi mom!')\n</code></pre>" =?> codeBlockWith ("c", [], []) "print('hi mom!')" ] |
