diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-12-15 23:45:34 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-12-15 23:45:34 -0800 |
commit | b4b4e32307499aafa2e6c1c713ee41f1c787ea76 (patch) | |
tree | 7bee37a1daf0a3c97d228646b66e79d4513d9f47 | |
parent | 8b872301eb68f0617c648cd6929ca8ff0ecbffd6 (diff) | |
download | pandoc-b4b4e32307499aafa2e6c1c713ee41f1c787ea76.tar.gz |
Properly handle boolean values in writing YAML metadata.
(Markdown writer.)
This requires doctemplates >= 0.9.
Closes #6388.
-rw-r--r-- | pandoc.cabal | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Shared.hs | 3 | ||||
-rw-r--r-- | stack.yaml | 5 | ||||
-rw-r--r-- | test/command/6388.md | 16 |
5 files changed, 25 insertions, 5 deletions
diff --git a/pandoc.cabal b/pandoc.cabal index 6483690b9..9244d25cd 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -410,7 +410,7 @@ library deepseq >= 1.3 && < 1.5, directory >= 1.2.3 && < 1.4, doclayout >= 0.3 && < 0.4, - doctemplates >= 0.8.2 && < 0.9, + doctemplates >= 0.9 && < 0.10, emojis >= 0.1 && < 0.2, exceptions >= 0.8 && < 0.11, file-embed >= 0.0 && < 0.1, @@ -767,7 +767,7 @@ test-suite test-pandoc bytestring >= 0.9 && < 0.12, containers >= 0.4.2.1 && < 0.7, directory >= 1.2.3 && < 1.4, - doctemplates >= 0.8.2 && < 0.9, + doctemplates >= 0.9 && < 0.10, exceptions >= 0.8 && < 0.11, executable-path >= 0.0 && < 0.1, filepath >= 1.1 && < 1.5, diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 5eb47b261..c349fd713 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -174,6 +174,8 @@ valToYaml :: Val Text -> Doc Text valToYaml (ListVal xs) = vcat $ map (\v -> hang 2 "- " (valToYaml v)) xs valToYaml (MapVal c) = contextToYaml c +valToYaml (BoolVal True) = "true" +valToYaml (BoolVal False) = "false" valToYaml (SimpleVal x) | isEmpty x = empty | otherwise = diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index b399afbf3..129e45e9d 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -109,8 +109,7 @@ metaValueToVal blockWriter inlineWriter (MetaMap metamap) = MapVal . Context <$> mapM (metaValueToVal blockWriter inlineWriter) metamap metaValueToVal blockWriter inlineWriter (MetaList xs) = ListVal <$> mapM (metaValueToVal blockWriter inlineWriter) xs -metaValueToVal _ _ (MetaBool True) = return $ SimpleVal "true" -metaValueToVal _ _ (MetaBool False) = return NullVal +metaValueToVal _ _ (MetaBool b) = return $ BoolVal b metaValueToVal _ inlineWriter (MetaString s) = SimpleVal <$> inlineWriter (Builder.toList (Builder.text s)) metaValueToVal blockWriter _ (MetaBlocks bs) = SimpleVal <$> blockWriter bs diff --git a/stack.yaml b/stack.yaml index ef0bc7a83..7c1bde8ae 100644 --- a/stack.yaml +++ b/stack.yaml @@ -16,7 +16,10 @@ extra-deps: - commonmark-0.1.1.2 - commonmark-extensions-0.2.0.4 - commonmark-pandoc-0.2.0.1 -- doctemplates-0.8.3 +# - doctemplates-0.8.3 +- doctemplates: + git: https://github.com/jgm/doctemplates.git + commit: 6cb8d09264f7c1f4b59ac67ff98b1a664a85e36a - citeproc-0.2.0.1 # - citeproc: # git: https://github.com/jgm/citeproc.git diff --git a/test/command/6388.md b/test/command/6388.md new file mode 100644 index 000000000..29a9156d7 --- /dev/null +++ b/test/command/6388.md @@ -0,0 +1,16 @@ +``` +% pandoc -t markdown -s +--- +nvalue: false +value: true +--- + +text +^D +--- +nvalue: false +value: true +--- + +text +``` |