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/Readers/Docx | |
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/Readers/Docx')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index 698d7a88a..fdcffcc3f 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -213,7 +213,7 @@ data ParIndentation = ParIndentation { leftParIndent :: Maybe Integer data ChangeType = Insertion | Deletion deriving Show -data ChangeInfo = ChangeInfo ChangeId Author ChangeDate +data ChangeInfo = ChangeInfo ChangeId Author (Maybe ChangeDate) deriving Show data TrackedChange = TrackedChange ChangeType ChangeInfo @@ -276,7 +276,7 @@ type Extent = Maybe (Double, Double) data ParPart = PlainRun Run | ChangedRuns TrackedChange [Run] - | CommentStart CommentId Author CommentDate [BodyPart] + | CommentStart CommentId Author (Maybe CommentDate) [BodyPart] | CommentEnd CommentId | BookMark BookMarkId Anchor | InternalHyperLink Anchor [Run] @@ -852,7 +852,7 @@ elemToCommentStart ns element | isElem ns "w" "comment" element , Just cmtId <- findAttrTextByName ns "w" "id" element , Just cmtAuthor <- findAttrTextByName ns "w" "author" element - , Just cmtDate <- findAttrTextByName ns "w" "date" element = do + , cmtDate <- findAttrTextByName ns "w" "date" element = do bps <- mapD (elemToBodyPart ns) (elChildren element) return $ CommentStart cmtId cmtAuthor cmtDate bps elemToCommentStart _ _ = throwError WrongElem @@ -958,14 +958,14 @@ getTrackedChange ns element | isElem ns "w" "ins" element || isElem ns "w" "moveTo" element , Just cId <- findAttrTextByName ns "w" "id" element , Just cAuthor <- findAttrTextByName ns "w" "author" element - , Just cDate <- findAttrTextByName ns "w" "date" element = - Just $ TrackedChange Insertion (ChangeInfo cId cAuthor cDate) + , mcDate <- findAttrTextByName ns "w" "date" element = + Just $ TrackedChange Insertion (ChangeInfo cId cAuthor mcDate) getTrackedChange ns element | isElem ns "w" "del" element || isElem ns "w" "moveFrom" element , Just cId <- findAttrTextByName ns "w" "id" element , Just cAuthor <- findAttrTextByName ns "w" "author" element - , Just cDate <- findAttrTextByName ns "w" "date" element = - Just $ TrackedChange Deletion (ChangeInfo cId cAuthor cDate) + , mcDate <- findAttrTextByName ns "w" "date" element = + Just $ TrackedChange Deletion (ChangeInfo cId cAuthor mcDate) getTrackedChange _ _ = Nothing elemToParagraphStyle :: NameSpaces -> Element -> ParStyleMap -> ParagraphStyle |