git.iko.soy/typeable/pandoc
on master help sign in
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.

commit4affd4019437a182c9e657f501d5eb057d8ea6ec authorJohn MacFarlane <jgm@berkeley.edu> dateMon 30 Dec 2019, 23:19 (7 years ago) parent5847624
1 file changed+5−3
src/Text/Pandoc/BCP47.hs+5−3
src/Text/Pandoc/BCP47.hs+5−3
@@ -46,9 +46,11 @@ getLang opts meta =
4646 Just s -> Just s
4747 _ ->
4848 case lookupMeta "lang" meta of
49− Just (MetaInlines [Str s]) -> Just s
50− Just (MetaString s) -> Just s
51− _ -> Nothing
49+ Just (MetaBlocks [Para [Str s]]) -> Just s
50+ Just (MetaBlocks [Plain [Str s]]) -> Just s
51+ Just (MetaInlines [Str s]) -> Just s
52+ Just (MetaString s) -> Just s
53+ _ -> Nothing
5254
5355-- | Parse a BCP 47 string as a Lang. Currently we parse
5456-- extensions and private-use fields as "variants," even