aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-06-22 13:49:19 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-06-23 10:50:46 -0400
commit8bb739f7ff353722981fe442ae0c137910604850 (patch)
treefa239e4f13e0174456fac3f96e84120d1b2f3cac /src/Text/Pandoc/Readers/Docx.hs
parentcbc2c15f0ffb1737a0f6540fb282adab7094423b (diff)
downloadpandoc-8bb739f7ff353722981fe442ae0c137910604850.tar.gz
Docx reader: add simple comment functionality.
This adds simple track-changes comment parsing to the docx reader. It is turned on with `--track-changes=all`. All comments are converted to inlines, which can list some information. In the future a warning will be added for comments with formatting that seems like it will be excessively denatured. Note that comments can extend across blocks. For that reason there are two spans: `comment-start` and `comment-end`. `comment-start` will contain the comment. `comment-end` will always be empty. The two will be associated by a numeric id.
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx.hs')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 9c7c3b264..610477f02 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -339,6 +339,22 @@ parPartToInlines (Deletion _ author date runs) = do
ils <- smushInlines <$> mapM runToInlines runs
let attr = ("", ["deletion"], [("author", author), ("date", date)])
return $ spanWith attr ils
+parPartToInlines (CommentStart cmtId author date bodyParts) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AllChanges -> do
+ blks <- smushBlocks <$> mapM bodyPartToBlocks bodyParts
+ let ils = fromList $ blocksToInlines $ toList blks
+ attr = ("", ["comment-start"], [("id", cmtId), ("author", author), ("date", date)])
+ return $ spanWith attr ils
+ _ -> return mempty
+parPartToInlines (CommentEnd cmtId) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AllChanges -> do
+ let attr = ("", ["comment-end"], [("id", cmtId)])
+ return $ spanWith attr mempty
+ _ -> return mempty
parPartToInlines (BookMark _ anchor) | anchor `elem` dummyAnchors =
return mempty
parPartToInlines (BookMark _ anchor) =