summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx/Parse.hs
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-11-10 13:00:42 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-11-10 13:19:27 -0500
commit7539de02873aa1095a3648e88fb9f5adda86c8fb (patch)
tree4401d8df43afed6423769aca88b7f583d5194963 /src/Text/Pandoc/Readers/Docx/Parse.hs
parent7e5220b57c5a48fabe6e43ba270db812593d3463 (diff)
Docx reader: Be more specific in parsing images
We not only want "w:drawing", because that could also include charts. Now we specify "w:drawing"//"pic:pic". This shouldn't change behavior at all, but it's a first step toward allowing other sorts of drawing data as well.
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx/Parse.hs')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 94e3e29cf..1d7b6088f 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -660,10 +660,12 @@ getTitleAndAlt ns element =
elemToParPart :: NameSpaces -> Element -> D ParPart
elemToParPart ns element
| isElem ns "w" "r" element
- , Just drawingElem <- findChild (elemName ns "w" "drawing") element =
- let (title, alt) = getTitleAndAlt ns drawingElem
+ , Just drawingElem <- findChild (elemName ns "w" "drawing") element
+ , pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
+ , Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) drawingElem
+ = let (title, alt) = getTitleAndAlt ns drawingElem
a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
- drawing = findElement (QName "blip" (Just a_ns) (Just "a")) element
+ drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
>>= findAttr (elemName ns "r" "embed")
in
case drawing of
@@ -764,10 +766,12 @@ elemToExtent drawingElem =
childElemToRun :: NameSpaces -> Element -> D Run
childElemToRun ns element
- | isElem ns "w" "drawing" element =
- let (title, alt) = getTitleAndAlt ns element
+ | isElem ns "w" "drawing" element
+ , pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
+ , Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) element
+ = let (title, alt) = getTitleAndAlt ns element
a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
- drawing = findElement (QName "blip" (Just a_ns) (Just "a")) element
+ drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
>>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))
in
case drawing of