From 740396d1ed91d03534b99ad8ccf545d916ee3f7a Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Wed, 28 Sep 2022 11:20:53 -0400 Subject: [PATCH] HTML Reader: Tests for 'tt' and 'code' elements (#8330). tt is a deprecated element in HTML, but is still used in the wild in some places, support reading it as just another 'code' element. Commit 4abb9d0ad8dbb88fbc443a78d5a1b116cb7a5816 was originally part of this PR as well. --- src/Text/Pandoc/Readers/HTML.hs | 2 +- test/Tests/Readers/HTML.hs | 12 ++++++++++++ test/Tests/Writers/HTML.hs | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 7d192a2d3..b3a2b8c42 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -662,7 +662,7 @@ inline = pTagText <|> do "img" -> pImage "svg" -> pSvg "bdo" -> pBdo - "tt" -> pCode + "tt" -> pCode "code" -> pCode "samp" -> pCodeWithClass "samp" "sample" "var" -> pCodeWithClass "var" "variable" diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs index eec5da643..b1d847354 100644 --- a/test/Tests/Readers/HTML.hs +++ b/test/Tests/Readers/HTML.hs @@ -98,6 +98,18 @@ tests = [ testGroup "base tag" , test htmlNativeDivs "
followed by text" $ "
main content
non-main content" =?> doc (divWith ("", [], [("role", "main")]) (plain (text "main content")) <> plain (text "non-main content")) ] + , testGroup "code" + [ + test html "inline code block" $ + "Answer is 42" =?> + plain (codeWith ("",[],[]) "Answer is 42") + ] + , testGroup "tt" + [ + test html "inline tt block" $ + "Answer is 42" =?> + plain (codeWith ("",[],[]) "Answer is 42") + ] , testGroup "samp" [ test html "inline samp block" $ diff --git a/test/Tests/Writers/HTML.hs b/test/Tests/Writers/HTML.hs index 5176af1f0..3ec7a866d 100644 --- a/test/Tests/Writers/HTML.hs +++ b/test/Tests/Writers/HTML.hs @@ -84,6 +84,11 @@ tests = doubleQuoted (spanWith ("", [], [("cite", "http://example.org")]) (str "examples")) =?> "examples" ] + , testGroup "code" + [ "code should be rendered correctly" =: + plain (codeWith ("",[],[]) "Answer is 42") =?> + "Answer is 42" + ] , testGroup "sample" [ "sample should be rendered correctly" =: plain (codeWith ("",["sample"],[]) "Answer is 42") =?>