aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-11-10 09:47:24 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-11-10 09:47:24 -0800
commit7d01887ddac1e0f9169037cd4c01ab6f2ed7ae3a (patch)
tree7b8a0d2fc2d67b262c19cc83d8967e3b7fbbbd85 /src/Text
parentcfb017c76b631164310f05f9498facd8b9037ed9 (diff)
downloadpandoc-7d01887ddac1e0f9169037cd4c01ab6f2ed7ae3a.tar.gz
Fix corner case in YAML metadata parsing.
Previously YAML metadata would sometimes not get recognized if a field ended with a newline followed by spaces. Closes #6823.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Metadata.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Metadata.hs b/src/Text/Pandoc/Readers/Metadata.hs
index b9a8653d5..9bf96f3c4 100644
--- a/src/Text/Pandoc/Readers/Metadata.hs
+++ b/src/Text/Pandoc/Readers/Metadata.hs
@@ -112,13 +112,16 @@ normalizeMetaValue pMetaValue x =
-- Note: a standard quoted or unquoted YAML value will
-- not end in a newline, but a "block" set off with
-- `|` or `>` will.
- if "\n" `T.isSuffixOf` x
+ if "\n" `T.isSuffixOf` (T.dropWhileEnd isSpaceChar x) -- see #6823
then parseFromString' pMetaValue (x <> "\n")
else parseFromString' asInlines x
where asInlines = fmap b2i <$> pMetaValue
b2i (MetaBlocks [Plain ils]) = MetaInlines ils
b2i (MetaBlocks [Para ils]) = MetaInlines ils
b2i bs = bs
+ isSpaceChar ' ' = True
+ isSpaceChar '\t' = True
+ isSpaceChar _ = False
checkBoolean :: Text -> Maybe Bool
checkBoolean t