git.iko.soy/typeable/pandoc
on master help sign in
Properly handle boolean values in writing YAML metadata.

(Markdown writer.) This requires doctemplates >= 0.9. Closes #6388.

commitb4b4e32307499aafa2e6c1c713ee41f1c787ea76 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 15 Dec 2020, 23:45 (6 years ago) parent8b87230
5 files changed+25−5
pandoc.cabal+2−2 src/Text/Pandoc/Writers/Markdown.hs+2 src/Text/Pandoc/Writers/Shared.hs+1−2 stack.yaml+4−1 test/command/6388.md+16
pandoc.cabal+2−2
@@ -410,7 +410,7 @@ library
410410 deepseq >= 1.3 && < 1.5,
411411 directory >= 1.2.3 && < 1.4,
412412 doclayout >= 0.3 && < 0.4,
413− doctemplates >= 0.8.2 && < 0.9,
413+ doctemplates >= 0.9 && < 0.10,
414414 emojis >= 0.1 && < 0.2,
415415 exceptions >= 0.8 && < 0.11,
416416 file-embed >= 0.0 && < 0.1,
@@ -767,7 +767,7 @@ test-suite test-pandoc
767767 bytestring >= 0.9 && < 0.12,
768768 containers >= 0.4.2.1 && < 0.7,
769769 directory >= 1.2.3 && < 1.4,
770− doctemplates >= 0.8.2 && < 0.9,
770+ doctemplates >= 0.9 && < 0.10,
771771 exceptions >= 0.8 && < 0.11,
772772 executable-path >= 0.0 && < 0.1,
773773 filepath >= 1.1 && < 1.5,
src/Text/Pandoc/Writers/Markdown.hs+2
@@ -174,6 +174,8 @@ valToYaml :: Val Text -> Doc Text
174174valToYaml (ListVal xs) =
175175 vcat $ map (\v -> hang 2 "- " (valToYaml v)) xs
176176valToYaml (MapVal c) = contextToYaml c
177+valToYaml (BoolVal True) = "true"
178+valToYaml (BoolVal False) = "false"
177179valToYaml (SimpleVal x)
178180 | isEmpty x = empty
179181 | otherwise =
src/Text/Pandoc/Writers/Shared.hs+1−2
@@ -109,8 +109,7 @@ metaValueToVal blockWriter inlineWriter (MetaMap metamap) =
109109 MapVal . Context <$> mapM (metaValueToVal blockWriter inlineWriter) metamap
110110metaValueToVal blockWriter inlineWriter (MetaList xs) = ListVal <$>
111111 mapM (metaValueToVal blockWriter inlineWriter) xs
112−metaValueToVal _ _ (MetaBool True) = return $ SimpleVal "true"
113−metaValueToVal _ _ (MetaBool False) = return NullVal
112+metaValueToVal _ _ (MetaBool b) = return $ BoolVal b
114113metaValueToVal _ inlineWriter (MetaString s) =
115114 SimpleVal <$> inlineWriter (Builder.toList (Builder.text s))
116115metaValueToVal blockWriter _ (MetaBlocks bs) = SimpleVal <$> blockWriter bs
stack.yaml+4−1
@@ -16,7 +16,10 @@ extra-deps:
1616- commonmark-0.1.1.2
1717- commonmark-extensions-0.2.0.4
1818- commonmark-pandoc-0.2.0.1
19−- doctemplates-0.8.3
19+# - doctemplates-0.8.3
20+- doctemplates:
21+ git: https://github.com/jgm/doctemplates.git
22+ commit: 6cb8d09264f7c1f4b59ac67ff98b1a664a85e36a
2023- citeproc-0.2.0.1
2124# - citeproc:
2225# git: https://github.com/jgm/citeproc.git
test/command/6388.mdnew file+16
@@ -0,0 +1,16 @@
1+```
2+% pandoc -t markdown -s
3+---
4+nvalue: false
5+value: true
6+---
7+
8+text
9+^D
10+---
11+nvalue: false
12+value: true
13+---
14+
15+text
16+```