From c0c8865eaac7089b0304c9b21d981f82ea4c2ebd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 20 Feb 2021 23:40:02 -0800 Subject: HTML reader: small performance tweak. --- src/Text/Pandoc/Readers/HTML.hs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 50201fe77..b73c138ab 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -157,11 +157,10 @@ pHead = pInTags "head" $ pTitle <|> pMetaTag <|> pBaseTag <|> (mempty <$ pAny) return mempty block :: PandocMonad m => TagParser m Blocks -block = do +block = ((do + tag <- lookAhead (pSatisfy isBlockTag) exts <- getOption readerExtensions - tag <- lookAhead pAny - res <- - (case tag of + case tag of TagOpen name attr -> let type' = fromMaybe "" $ lookup "type" attr <|> lookup "epub:type" attr @@ -214,11 +213,8 @@ block = do | epubExts -> eSwitch B.para block _ -> mzero - _ -> mzero) - <|> pPlain - <|> pRawHtmlBlock - trace (T.take 60 $ tshow $ B.toList res) - return res + _ -> mzero) <|> pPlain <|> pRawHtmlBlock) >>= \res -> + res <$ trace (T.take 60 $ tshow $ B.toList res) namespaces :: PandocMonad m => [(Text, TagParser m Inlines)] namespaces = [(mathMLNamespace, pMath True)] -- cgit v1.2.3