@@ -35,7 +35,7 @@ import Data.List ( transpose, sortBy, intersperse, intercalate, elemIndex)
3535import qualified Data.Map as M
3636import Data.Scientific (coefficient, base10Exponent)
3737import Data.Ord ( comparing )
38−import Data.Char ( isAlphaNum, toLower )
38+import Data.Char ( isSpace, isAlphaNum, toLower )
3939import Data.Maybe
4040import Text.Pandoc.Definition
4141import qualified Data.Text as T
@@ -281,13 +281,18 @@ ignorable t = T.pack "_" `T.isSuffixOf` t
281281
282282toMetaValue :: ReaderOptions -> Text -> MetaValue
283283toMetaValue opts x =
284− case readMarkdown opts (T.unpack x) of
284+ case readMarkdown opts' (T.unpack x) of
285285 Pandoc _ [Plain xs] -> MetaInlines xs
286286 Pandoc _ [Para xs]
287287 | endsWithNewline x -> MetaBlocks [Para xs]
288288 | otherwise -> MetaInlines xs
289289 Pandoc _ bs -> MetaBlocks bs
290290 where endsWithNewline t = T.pack "\n" `T.isSuffixOf` t
291+ opts' = opts{readerExtensions=readerExtensions opts `Set.difference` meta_exts}
292+ meta_exts = Set.fromList [ Ext_pandoc_title_block
293+ , Ext_mmd_title_block
294+ , Ext_yaml_metadata_block
295+ ]
291296
292297yamlToMeta :: ReaderOptions -> Yaml.Value -> MetaValue
293298yamlToMeta opts (Yaml.String t) = toMetaValue opts t
@@ -321,11 +326,15 @@ mmdTitleBlock = try $ do
321326kvPair :: MarkdownParser (String, MetaValue)
322327kvPair = try $ do
323328 key <- many1Till (alphaNum <|> oneOf "_- ") (char ':')
329+ skipMany1 spaceNoNewline
324330 val <- manyTill anyChar
325331 (try $ newline >> lookAhead (blankline <|> nonspaceChar))
332+ guard $ not . null . trim $ val
326333 let key' = concat $ words $ map toLower key
327334 let val' = MetaBlocks $ B.toList $ B.plain $ B.text $ trim val
328335 return (key',val')
336+ where
337+ spaceNoNewline = satisfy (\x -> isSpace x && (x/='\n') && (x/='\r'))
329338
330339parseMarkdown :: MarkdownParser Pandoc
331340parseMarkdown = do