git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Fixed bugs in YAML header output.
commit8d43e08ce7be8673cc399b948d29386f525e9e1f authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 6 Sep 2013, 22:26 (13 years ago) parent728e47a
2 files changed+4−4
src/Text/Pandoc/Writers/Markdown.hs+3−3 tests/writer.markdown+1−1
src/Text/Pandoc/Writers/Markdown.hs+3−3
@@ -39,7 +39,7 @@ import Text.Pandoc.Writers.Shared
3939import Text.Pandoc.Options
4040import Text.Pandoc.Parsing hiding (blankline, char, space)
4141import Data.List ( group, isPrefixOf, find, intersperse, transpose, sortBy )
42−import Data.Char ( isSpace )
42+import Data.Char ( isSpace, isPunctuation )
4343import Data.Ord ( comparing )
4444import Text.Pandoc.Pretty
4545import Control.Monad.State
@@ -143,7 +143,7 @@ jsonToYaml (Object hashmap) =
143143 | otherwise -> (k' <> ":") $$ x
144144 (k', Object _, x) -> (k' <> ":") $$ nest 2 x
145145 (_, String "", _) -> empty
146− (k', _, x) -> k' <> ":" <> space <> x)
146+ (k', _, x) -> k' <> ":" <> space <> hang 2 "" x)
147147 $ sortBy (comparing fst) $ H.toList hashmap
148148jsonToYaml (Array vec) =
149149 vcat $ map (\v -> hang 2 "- " (jsonToYaml v)) $ V.toList vec
@@ -151,7 +151,7 @@ jsonToYaml (String "") = empty
151151jsonToYaml (String s) =
152152 case T.unpack s of
153153 x | '\n' `elem` x -> hang 2 ("|" <> cr) $ text x
154− | not (any (`elem` x) "\"'#:[]{}?-") -> text x
154+ | not (any isPunctuation x) -> text x
155155 | otherwise -> text $ "'" ++ substitute "'" "''" x ++ "'"
156156jsonToYaml (Bool b) = text $ show b
157157jsonToYaml (Number n) = text $ show n
tests/writer.markdown+1−1
@@ -2,7 +2,7 @@
22author:
33- John MacFarlane
44- Anonymous
5−date: July 17, 2006
5+date: 'July 17, 2006'
66title: Pandoc Test Suite
77...
88