aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs9
-rw-r--r--test/Tests/Readers/HTML.hs6
2 files changed, 15 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index a9a04c962..b6f88d3a9 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -652,6 +652,7 @@ inline = choice
, pLink
, pImage
, pCode
+ , pSamp
, pSpan
, pMath False
, pScriptMath
@@ -781,6 +782,14 @@ pImage = do
let kvs = concatMap getAtt ["width", "height", "sizes", "srcset"]
return $ B.imageWith (uid, cls, kvs) (escapeURI url) title (B.text alt)
+pSamp :: PandocMonad m => TagParser m Inlines
+pSamp = try $ do
+ TagOpen open attr' <- pSatisfy $ tagOpen (=="samp") (const True)
+ result <- manyTill pAny (pCloses open)
+ let (ids,cs,kvs) = mkAttr . toStringAttr $ attr'
+ return . B.codeWith (ids,"sample":cs,kvs) .
+ unwords . lines . T.unpack . innerText $ result
+
pCode :: PandocMonad m => TagParser m Inlines
pCode = try $ do
(TagOpen open attr') <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
index be5178e07..17ca717ea 100644
--- a/test/Tests/Readers/HTML.hs
+++ b/test/Tests/Readers/HTML.hs
@@ -89,6 +89,12 @@ tests = [ testGroup "base tag"
, test htmlNativeDivs "<main> followed by text" $ "<main>main content</main>non-main content" =?>
doc (divWith ("", [], [("role", "main")]) (plain (text "main content")) <> plain (text "non-main content"))
]
+ , testGroup "samp"
+ [
+ test html "inline samp block" $
+ "<samp>Answer is 42</samp>" =?>
+ plain (codeWith ("",["sample"],[]) "Answer is 42")
+ ]
, askOption $ \(QuickCheckTests numtests) ->
testProperty "Round trip" $
withMaxSuccess (if QuickCheckTests numtests == defaultValue