From eb11c61182032129d7f4824de2afff61b662b9db Mon Sep 17 00:00:00 2001
From: Jesse Rosenthal <jrosenthal@jhu.edu>
Date: Mon, 19 Jan 2015 11:40:33 -0500
Subject: Docx: Parse images in deprecated vml format.

Some older versions of word use vml (vector markup language) and put
their images in a "v:imagedata" tag inside a "w:pict". We read those as
we read the more modern "blip" inside a "w:drawing".

Note that this does not mean the reader knows anything about vml. It
just looks for a `v:imagdata`. It's possible that, with more complicated
uses of images in vml, it won't do the right thing.
---
 src/Text/Pandoc/Readers/Docx/Parse.hs | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'src')

diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 5fd6b7a81..671d2acf3 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -639,6 +639,16 @@ elemToParPart ns element
      case drawing of
        Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp bs)
        Nothing -> throwError WrongElem
+-- The below is an attempt to deal with images in deprecated vml format.
+elemToParPart ns element
+  | isElem ns "w" "r" element
+  , Just _ <- findChild (elemName ns "w" "pict") element =
+    let drawing = findElement (elemName ns "v" "imagedata") element
+                  >>= findAttr (elemName ns "r" "id")
+    in
+     case drawing of
+       Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp bs)
+       Nothing -> throwError WrongElem
 elemToParPart ns element
   | isElem ns "w" "r" element =
     elemToRun ns element >>= (\r -> return $ PlainRun r)
-- 
cgit v1.2.3