Sort YAML metadata keys in Markdown output case-insensitive.

Use caseFold.
This commit is contained in:
John MacFarlane 2020-09-13 14:11:07 -07:00
parent 045dd212a7
commit 39f357027a

View file

@ -126,7 +126,7 @@ pandocTitleBlock tit auths dat =
mmdTitleBlock :: Context Text -> Doc Text mmdTitleBlock :: Context Text -> Doc Text
mmdTitleBlock (Context hashmap) = 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) = where go (k,v) =
case (text (T.unpack k), v) of case (text (T.unpack k), v) of
(k', ListVal xs) (k', ListVal xs)
@ -155,7 +155,7 @@ yamlMetadataBlock v = "---" $$ contextToYaml v $$ "---"
contextToYaml :: Context Text -> Doc Text contextToYaml :: Context Text -> Doc Text
contextToYaml (Context o) = contextToYaml (Context o) =
vcat $ map keyvalToYaml $ sortOn fst $ M.toList o vcat $ map keyvalToYaml $ sortOn (T.toCaseFold . fst) $ M.toList o
where where
keyvalToYaml (k,v) = keyvalToYaml (k,v) =
case (text (T.unpack k), v) of case (text (T.unpack k), v) of