diff options
author | Amogh Rathore <amoghdroid09@gmail.com> | 2019-11-05 01:42:30 +0900 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-11-04 08:42:30 -0800 |
commit | bd2bd9b19d949f59a64358f756bf8b398a13db0f (patch) | |
tree | a266e1c6ae9a0d183695bd82e9cd5a89e12d8970 /src/Text/Pandoc/Readers | |
parent | fdc0f47519d330bcc641eeaee68486431d3c46a5 (diff) | |
download | pandoc-bd2bd9b19d949f59a64358f756bf8b398a13db0f.tar.gz |
HTML Reader/Writer - Add support for <var> and <samp> (#5861)
Closes #5799
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 1ed61591b..c5abe0e15 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -652,7 +652,7 @@ inline = choice , pLink , pImage , pCode - , pSamp + , pCodeWithClass [(T.pack "samp","sample"),(T.pack "var","variable")] , pSpan , pMath False , pScriptMath @@ -782,12 +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) +pCodeWithClass :: PandocMonad m => [(T.Text,String)] -> TagParser m Inlines +pCodeWithClass elemToClass = try $ do + let tagTest = flip elem . fmap fst $ elemToClass + TagOpen open attr' <- pSatisfy $ tagOpen tagTest (const True) result <- manyTill pAny (pCloses open) let (ids,cs,kvs) = mkAttr . toStringAttr $ attr' - return . B.codeWith (ids,"sample":cs,kvs) . + cs' = maybe cs (:cs) . lookup open $ elemToClass + return . B.codeWith (ids,cs',kvs) . unwords . lines . T.unpack . innerText $ result pCode :: PandocMonad m => TagParser m Inlines |