From 38e1d3e95b8240eeb35db0a1a56e308cfb4835e4 Mon Sep 17 00:00:00 2001
From: Jesse Rosenthal <jrosenthal@jhu.edu>
Date: Wed, 25 Jun 2014 10:32:48 -0400
Subject: Docx reader: Parse Insertions and Deletions.

This is just for the Parse module, reading it into the Docx format. It
still has to be translated into pandoc.
---
 src/Text/Pandoc/Readers/Docx/Parse.hs | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 1cb5fe2e3..c76ef7511 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -541,7 +541,7 @@ elemToRun _ _ = Nothing
 
 elemToRunElem :: NameSpaces -> Element -> Maybe RunElem
 elemToRunElem ns element
-  | qName (elName element) == "t" &&
+  | (qName (elName element) == "t" || qName (elName element) == "delText") &&
     qURI (elName element) == (lookup "w" ns) =
       Just $ TextRun (strContent element)
   | qName (elName element) == "br" &&
@@ -581,6 +581,22 @@ elemToParPart ns element
         Nothing -> do
           r <- elemToRun ns element
           return $ PlainRun r
+elemToParPart ns element
+  | qName (elName element) == "ins" &&
+    qURI (elName element) == (lookup "w" ns) = do
+      cId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+      cAuthor <- findAttr (QName "author" (lookup "w" ns) (Just "w")) element
+      cDate <- findAttr (QName "date" (lookup "w" ns) (Just "w")) element
+      let runs = mapMaybe (elemToRun ns) (elChildren element)
+      return $ Insertion cId cAuthor cDate runs
+elemToParPart ns element
+  | qName (elName element) == "del" &&
+    qURI (elName element) == (lookup "w" ns) = do
+      cId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+      cAuthor <- findAttr (QName "author" (lookup "w" ns) (Just "w")) element
+      cDate <- findAttr (QName "date" (lookup "w" ns) (Just "w")) element
+      let runs = mapMaybe (elemToRun ns) (elChildren element)
+      return $ Deletion cId cAuthor cDate runs
 elemToParPart ns element
   | qName (elName element) == "bookmarkStart" &&
     qURI (elName element) == (lookup "w" ns) = do
-- 
cgit v1.2.3