aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-12-30 23:19:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-12-30 23:21:22 -0700
commit4affd4019437a182c9e657f501d5eb057d8ea6ec (patch)
tree80d2e2ef0cad01d7587691538343e9ceb00af5ec /src/Text
parent5847624124b4c91ae0a64b76405a36ad4f0dc3c4 (diff)
downloadpandoc-4affd4019437a182c9e657f501d5eb057d8ea6ec.tar.gz
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.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/BCP47.hs8
1 files changed, 5 insertions, 3 deletions
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