Skip to content

Commit

Permalink
Markdown Reader: Disable meta exts for meta values
Browse files Browse the repository at this point in the history
Disable all metadata block extensions when parsing metadata field
values. Issue jgm#2026
  • Loading branch information
lierdakil committed Mar 27, 2015
1 parent d09b759 commit 6960b2a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Text/Pandoc/Readers/Markdown.hs
Expand Up @@ -281,13 +281,18 @@ ignorable t = T.pack "_" `T.isSuffixOf` t

toMetaValue :: ReaderOptions -> Text -> MetaValue
toMetaValue opts x =
case readMarkdown opts (T.unpack x) of
case readMarkdown opts' (T.unpack x) of
Pandoc _ [Plain xs] -> MetaInlines xs
Pandoc _ [Para xs]
| endsWithNewline x -> MetaBlocks [Para xs]
| otherwise -> MetaInlines xs
Pandoc _ bs -> MetaBlocks bs
where endsWithNewline t = T.pack "\n" `T.isSuffixOf` t
opts' = opts{readerExtensions=readerExtensions opts `Set.difference` meta_exts}
meta_exts = Set.fromList [ Ext_pandoc_title_block
, Ext_mmd_title_block
, Ext_yaml_metadata_block
]

yamlToMeta :: ReaderOptions -> Yaml.Value -> MetaValue
yamlToMeta opts (Yaml.String t) = toMetaValue opts t
Expand Down

0 comments on commit 6960b2a

Please sign in to comment.