aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt8
-rw-r--r--src/Text/Pandoc/Readers/Metadata.hs10
-rw-r--r--test/command/literal-tag.md10
3 files changed, 23 insertions, 5 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 891f37cf8..c45e8b3d9 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -3914,7 +3914,8 @@ from the main markdown input document.
Metadata will be taken from the fields of the YAML object and added to any
existing document metadata. Metadata can contain lists and objects (nested
-arbitrarily), but all string scalars will be interpreted as Markdown. Fields
+arbitrarily), but all string scalars will be interpreted as
+Markdown, unless marked with the YAML tag `!!literal`. Fields
with names ending in an underscore will be ignored by pandoc. (They may be
given a role by external processors.) Field names must not be
interpretable as YAML numbers or boolean values (so, for
@@ -3945,6 +3946,11 @@ when the field contains blank lines or block-level formatting:
This is the abstract.
It consists of two paragraphs.
+
+ # This is a YAML comment; it will be ignored.
+ # The following field is marked as literal and will be
+ # interpreted as a literal string rather than Markdown:
+ catalog_number: !!literal '*abc123<f>*'
...
Template variables will be set automatically from the metadata. Thus, for
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
diff --git a/test/command/literal-tag.md b/test/command/literal-tag.md
new file mode 100644
index 000000000..4bbefab7c
--- /dev/null
+++ b/test/command/literal-tag.md
@@ -0,0 +1,10 @@
+```
+% pandoc -t native -s
+---
+hi: !!literal '*ook*'
+there: '*ook*'
+...
+^D
+Pandoc (Meta {unMeta = fromList [("hi",MetaString "*ook*"),("there",MetaInlines [Emph [Str "ook"]])]})
+[]
+```