From 3ec62d006483d369bb896b283db82e4437b66d05 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 25 Jun 2014 13:50:08 -0400 Subject: Add TrackChanges type to options. --- src/Text/Pandoc/Options.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 611a6bb06..e0ad866ad 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -264,6 +264,12 @@ data HTMLSlideVariant = S5Slides | NoSlides deriving (Show, Read, Eq) +-- | Options for accepting or rejecting MS Word track-changes. +data TrackChanges = AcceptChanges + | RejectChanges + | AllChanges + deriving (Show, Read, Eq) + -- | Options for writers data WriterOptions = WriterOptions { writerStandalone :: Bool -- ^ Include header and footer -- cgit v1.2.3 From 6ff84b5e8da47ff7f4b77bd6cd017beae81fed97 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 25 Jun 2014 13:57:56 -0400 Subject: Add reader option for track changes. --- src/Text/Pandoc/Options.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index e0ad866ad..d0a76a001 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -211,6 +211,7 @@ data ReaderOptions = ReaderOptions{ -- indented code blocks , readerDefaultImageExtension :: String -- ^ Default extension for images , readerTrace :: Bool -- ^ Print debugging info + , readerTrackChanges :: TrackChanges } deriving (Show, Read) instance Default ReaderOptions @@ -227,6 +228,7 @@ instance Default ReaderOptions , readerIndentedCodeClasses = [] , readerDefaultImageExtension = "" , readerTrace = False + , readerTrackChanges = AcceptChanges } -- -- cgit v1.2.3 From d824f89fb3996fd27e156da1141808fbf468819d Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 25 Jun 2014 14:05:21 -0400 Subject: Add TrackChanges to Options export. --- src/Text/Pandoc/Options.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index d0a76a001..b7a3a4b7b 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -41,6 +41,7 @@ module Text.Pandoc.Options ( Extension(..) , HTMLSlideVariant (..) , EPUBVersion (..) , WriterOptions (..) + , TrackChanges (..) , def , isEnabled ) where -- cgit v1.2.3 From 0e9bf37f64be0a121a0d682570fc8f0cf2b27c51 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Wed, 25 Jun 2014 14:17:20 -0400 Subject: Docx reader: Make use of track-changes option. --- src/Text/Pandoc/Readers/Docx.hs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 130e2a1e2..cb0735e31 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -234,9 +234,22 @@ runToInlines opts docx@(Docx _ notes _ _ _) (Endnote fnId) = parPartToInlines :: ReaderOptions -> Docx -> ParPart -> [Inline] parPartToInlines opts docx (PlainRun r) = runToInlines opts docx r -parPartToInlines opts docx (Insertion _ _ _ runs) = - concatMap (runToInlines opts docx) runs -parPartToInlines _ _ (Deletion _ _ _ _) = [] +parPartToInlines opts docx (Insertion _ author date runs) = + case readerTrackChanges opts of + AcceptChanges -> concatMap (runToInlines opts docx) runs + RejectChanges -> [] + AllChanges -> + [Span + ("", ["insertion"], [("author", author), ("date", date)]) + (concatMap (runToInlines opts docx) runs)] +parPartToInlines opts docx (Deletion _ author date runs) = + case readerTrackChanges opts of + AcceptChanges -> [] + RejectChanges -> concatMap (runToInlines opts docx) runs + AllChanges -> + [Span + ("", ["deletion"], [("author", author), ("date", date)]) + (concatMap (runToInlines opts docx) runs)] parPartToInlines _ _ (BookMark _ anchor) | anchor `elem` dummyAnchors = [] parPartToInlines _ _ (BookMark _ anchor) = [Span (anchor, ["anchor"], []) []] parPartToInlines _ (Docx _ _ _ rels _) (Drawing relid) = -- cgit v1.2.3