From 4affd4019437a182c9e657f501d5eb057d8ea6ec Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 30 Dec 2019 23:19:46 -0700 Subject: BCP47: change getLang so it can handle block-level contents. Some readers (e.g. RST) will populate the `lang` metadata field with block-level content. `getLang` has been modified to handle this. Previously in these cases the LaTeX writer would not properly set the "main language" of the document. Closes #6008. --- src/Text/Pandoc/BCP47.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/BCP47.hs b/src/Text/Pandoc/BCP47.hs index f4afec90c..e25134976 100644 --- a/src/Text/Pandoc/BCP47.hs +++ b/src/Text/Pandoc/BCP47.hs @@ -46,9 +46,11 @@ getLang opts meta = Just s -> Just s _ -> case lookupMeta "lang" meta of - Just (MetaInlines [Str s]) -> Just s - Just (MetaString s) -> Just s - _ -> Nothing + Just (MetaBlocks [Para [Str s]]) -> Just s + Just (MetaBlocks [Plain [Str s]]) -> Just s + Just (MetaInlines [Str s]) -> Just s + Just (MetaString s) -> Just s + _ -> Nothing -- | Parse a BCP 47 string as a Lang. Currently we parse -- extensions and private-use fields as "variants," even -- cgit v1.2.3