From 39f357027aafeed5f20f350db0a892b9cc3efd43 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 13 Sep 2020 14:11:07 -0700 Subject: [PATCH] Sort YAML metadata keys in Markdown output case-insensitive. Use caseFold. --- src/Text/Pandoc/Writers/Markdown.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 323d159b0..f0643c91b 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -126,7 +126,7 @@ pandocTitleBlock tit auths dat = mmdTitleBlock :: Context Text -> Doc Text mmdTitleBlock (Context hashmap) = - vcat $ map go $ sortOn fst $ M.toList hashmap + vcat $ map go $ sortOn (T.toCaseFold . fst) $ M.toList hashmap where go (k,v) = case (text (T.unpack k), v) of (k', ListVal xs) @@ -155,7 +155,7 @@ yamlMetadataBlock v = "---" $$ contextToYaml v $$ "---" contextToYaml :: Context Text -> Doc Text contextToYaml (Context o) = - vcat $ map keyvalToYaml $ sortOn fst $ M.toList o + vcat $ map keyvalToYaml $ sortOn (T.toCaseFold . fst) $ M.toList o where keyvalToYaml (k,v) = case (text (T.unpack k), v) of