aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-02-20 23:40:02 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-02-20 23:40:02 -0800
commitc0c8865eaac7089b0304c9b21d981f82ea4c2ebd (patch)
treecefb486048c49477473258745124992a68923333
parentd8ef383692a167c97c67114107878a60d0aee6e1 (diff)
downloadpandoc-c0c8865eaac7089b0304c9b21d981f82ea4c2ebd.tar.gz
HTML reader: small performance tweak.
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs14
1 files 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)]