diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-12-10 15:51:20 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-12-10 15:51:20 -0800 |
commit | fcd065818901e57f01aca4c919f6102f9a047ba0 (patch) | |
tree | 0ee337f508e592ce51a6d5543057e903d0f12b60 | |
parent | 0a502e5ff52b251bbf3da69fd1f9a88d5e0fe92c (diff) | |
download | pandoc-fcd065818901e57f01aca4c919f6102f9a047ba0.tar.gz |
HTML reader: pay attention to lang attributes on body.
These (as well as lang attributes on html) should update
lang in metadata. See #6938.
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index f870a241d..f8a17bb78 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -25,7 +25,6 @@ module Text.Pandoc.Readers.HTML ( readHtml ) where import Control.Applicative ((<|>)) -import Control.Arrow (first) import Control.Monad (guard, msum, mzero, unless, void) import Control.Monad.Except (throwError) import Control.Monad.Reader (ask, asks, lift, local, runReaderT) @@ -121,14 +120,18 @@ setInPlain :: PandocMonad m => HTMLParser m s a -> HTMLParser m s a setInPlain = local (\s -> s {inPlain = True}) pHtml :: PandocMonad m => TagParser m Blocks -pHtml = try $ do +pHtml = do (TagOpen "html" attr) <- lookAhead pAny for_ (lookup "lang" attr <|> lookup "xml:lang" attr) $ updateState . B.setMeta "lang" . B.text pInTags "html" block pBody :: PandocMonad m => TagParser m Blocks -pBody = pInTags "body" block +pBody = do + (TagOpen "body" attr) <- lookAhead pAny + for_ (lookup "lang" attr <|> lookup "xml:lang" attr) $ + updateState . B.setMeta "lang" . B.text + pInTags "body" block pHead :: PandocMonad m => TagParser m Blocks pHead = pInTags "head" $ pTitle <|> pMetaTag <|> pBaseTag <|> (mempty <$ pAny) |