aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-02-17 09:53:36 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-02-17 09:53:36 -0800
commit3493d6afaa6586c46898cf8bdb0c45bb70d31f28 (patch)
treef3502747a8e9113391eefeb83e1f8eb990d62eeb /src/Text/Pandoc
parent6a01386cd1e562eb3d75975e63c0df1491ecc01e (diff)
downloadpandoc-3493d6afaa6586c46898cf8bdb0c45bb70d31f28.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Metadata.hs10
1 files changed, 6 insertions, 4 deletions
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