diff options
author | Diego Balseiro <dbalseiro@stackbuilders.com> | 2020-10-06 23:03:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 21:03:00 -0700 |
commit | eda5540719e9771b48f15aa7f431033163e1f161 (patch) | |
tree | 261e3854c0c901ca6039cb8e3e2a27d6e4da4787 /src/Text/Pandoc/Writers | |
parent | a27a0b5419d8abdb374fac7cddc6f9ce128c0f96 (diff) | |
download | pandoc-eda5540719e9771b48f15aa7f431033163e1f161.tar.gz |
DOCX reader: Allow empty dates in comments and tracked changes (#6726)
For security reasons, some legal firms delete the date from comments and
tracked changes.
* Make date optional (Maybe) in tracked changes and comments datatypes
* Add tests
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index a7720eb53..93f7dd799 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1244,33 +1244,29 @@ inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do else id) getChangeAuthorDate = do defaultAuthor <- asks envChangesAuthor - defaultDate <- asks envChangesDate let author = fromMaybe defaultAuthor (lookup "author" kvs) - date = fromMaybe defaultDate (lookup "date" kvs) - return (author, date) + let mdate = lookup "date" kvs + return $ ("w:author", T.unpack author) : + maybe [] (\date -> [("w:date", T.unpack date)]) mdate insmod <- if "insertion" `elem` classes then do - (author, date) <- getChangeAuthorDate + changeAuthorDate <- getChangeAuthorDate insId <- gets stInsId modify $ \s -> s{stInsId = insId + 1} return $ \f -> do x <- f return [ mknode "w:ins" - [("w:id", show insId), - ("w:author", T.unpack author), - ("w:date", T.unpack date)] x ] + (("w:id", show insId) : changeAuthorDate) x] else return id delmod <- if "deletion" `elem` classes then do - (author, date) <- getChangeAuthorDate + changeAuthorDate <- getChangeAuthorDate delId <- gets stDelId modify $ \s -> s{stDelId = delId + 1} return $ \f -> local (\env->env{envInDel=True}) $ do x <- f return [mknode "w:del" - [("w:id", show delId), - ("w:author", T.unpack author), - ("w:date", T.unpack date)] x] + (("w:id", show delId) : changeAuthorDate) x] else return id contents <- insmod $ delmod $ dirmod $ stylemod $ pmod $ inlinesToOpenXML opts ils |