summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs5
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs3
2 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 4dc9543cf..57f6e4c1c 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -56,6 +56,7 @@ module Text.Pandoc.Readers.Docx.Parse ( Docx(..)
, constructBogusParStyleData
, leftBiasedMergeRunStyle
, rowsToRowspans
+ , extractTarget
) where
import Text.Pandoc.Readers.Docx.Parse.Styles
import Codec.Archive.Zip
@@ -538,6 +539,10 @@ relElemToRelationship fp relType element | qName (elName element) == "Relationsh
return $ Relationship relType relId target'
relElemToRelationship _ _ _ = Nothing
+extractTarget :: Element -> Maybe Target
+extractTarget element = do (Relationship _ _ target) <- relElemToRelationship "word/" InDocument element
+ return target
+
filePathToRelationships :: Archive -> FilePath -> FilePath -> [Relationship]
filePathToRelationships ar docXmlPath fp
| Just relType <- filePathToRelType fp docXmlPath
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index afafd6926..07633922f 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -64,6 +64,7 @@ import Text.Pandoc.ImageSize
import Text.Pandoc.Logging
import Text.Pandoc.MIME (extensionFromMimeType, getMimeType, getMimeTypeDef)
import Text.Pandoc.Options
+import Text.Pandoc.Readers.Docx.Parse (extractTarget)
import Text.Pandoc.Writers.Docx.StyleMap
import Text.Pandoc.Writers.Docx.Table as Table
import Text.Pandoc.Writers.Docx.Types
@@ -310,8 +311,6 @@ writeDocx opts doc = do
let headers = filterElements isHeaderNode parsedRels
let footers = filterElements isFooterNode parsedRels
- let extractTarget = findAttr (QName "Target" Nothing Nothing)
-
-- we create [Content_Types].xml and word/_rels/document.xml.rels
-- from scratch rather than reading from reference.docx,
-- because Word sometimes changes these files when a reference.docx is modified,