Docx writer: fix empty keywords in core document properties#11666
Conversation
stringify returns the empty string for a MetaString, so each keyword in the cp:keywords list of docProps/core.xml was rendered as empty. Convert each metadata value like lookupMetaString does instead.
| let metaValueToText (MetaString s) = s | ||
| metaValueToText (MetaInlines ils) = stringify ils | ||
| metaValueToText (MetaBlocks bs) = stringify bs | ||
| metaValueToText (MetaBool b) = T.pack (show b) | ||
| metaValueToText _ = "" |
There was a problem hiding this comment.
Why not just use lookupMetaString from T.P.Writers.Shared, instead of reproducing the code?
There was a problem hiding this comment.
Good call. Replaced the local helper with lookupMetaString "x" (Meta $ M.singleton "x" v) so the conversion logic lives in one place. Pushed.
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
| Just (MetaList xs) -> map metaValueToText xs | ||
| Just (MetaList xs) -> map toText xs |
There was a problem hiding this comment.
Sorry, when I made my suggestion I hadn't taken into account the need to create these singleton Meta values, which is going to introduce unnecessary allocations. I now think it's cleaner to use the original approach, or we could provide metaValueToText as an exported function in T.P.Writers.Shared and use it both here and in the definition of lookupMetaString.
There was a problem hiding this comment.
Reverted to the local helper. Thanks for the clarification.
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
`stringify` returns the empty string for a MetaString, so each keyword in the `cp:keywords` list of `docProps/core.xml` was rendered as empty. Convert each metadata value like `lookupMetaString` does instead. Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Fixes #11665.
When keywords are supplied as a metadata list, every entry in
<cp:keywords>ofdocProps/core.xmlwas rendered empty:The list elements are
MetaStringvalues, andstringifyreturns the empty string for aMetaString(it only collectsInlines). The fix converts each element the same waylookupMetaStringdoes, soMetaString/MetaInlines/MetaBlocksare all handled.Verified the repro and the fix output against pandoc 3.9. I was not able to run the docx golden-test harness locally (no GHC toolchain available); happy to add a core.xml properties test if you'd like one.