From 3493d6afaa6586c46898cf8bdb0c45bb70d31f28 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 17 Feb 2020 09:53:36 -0800 Subject: Allow specifying string value in metadata using `!!literal` tag. This is experimental. Normally metadata values are interpreted as markdown, but if the !!literal tag is used they will be interpreted as plain strings. We need to consider whether this can still be implemented if we switch back from HsYAML to yaml for performance reasons. --- src/Text/Pandoc/Readers/Metadata.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Metadata.hs b/src/Text/Pandoc/Readers/Metadata.hs index 23ceb40f9..d91c4a406 100644 --- a/src/Text/Pandoc/Readers/Metadata.hs +++ b/src/Text/Pandoc/Readers/Metadata.hs @@ -99,10 +99,12 @@ yamlToMetaValue pBlocks (YAML.Scalar _ x) = YAML.SBool b -> return $ return $ MetaBool b YAML.SFloat d -> return $ return $ MetaString $ tshow d YAML.SInt i -> return $ return $ MetaString $ tshow i - YAML.SUnknown _ t -> - case checkBoolean t of - Just b -> return $ return $ MetaBool b - Nothing -> toMetaValue pBlocks t + YAML.SUnknown tag t + | (T.takeWhileEnd (/= ':') <$> YE.tagToText tag) == + Just "literal" -> return $ return $ MetaString t + | otherwise -> case checkBoolean t of + Just b -> return $ return $ MetaBool b + Nothing -> toMetaValue pBlocks t YAML.SNull -> return $ return $ MetaString "" yamlToMetaValue pBlocks (YAML.Sequence _ _ xs) = do -- cgit v1.2.3