From 7d01887ddac1e0f9169037cd4c01ab6f2ed7ae3a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 10 Nov 2020 09:47:24 -0800 Subject: 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. --- src/Text/Pandoc/Readers/Metadata.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text') 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 -- cgit v1.2.3