@@ -166,8 +166,17 @@ writeDocx mbRefDocx opts doc@(Pandoc (Meta tit auths date) _) = do
166166 : mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] () -- put current time here
167167 : map (mknode "dc:creator" [] . stringify) auths
168168 let docPropsEntry = toEntry docPropsPath epochtime $ fromString $ showTopElement' docProps
169+ let relsPath = "_rels/.rels"
170+ rels <- case findEntryByPath relsPath refArchive of
171+ Just e -> return $ toString $ fromEntry e
172+ Nothing -> err 57 "could not find .rels/_rels in reference docx"
173+ -- fix .rels/_rels, which can get screwed up when reference.docx is edited by Word
174+ let rels' = substitute "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
175+ "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties"
176+ rels
177+ let relsEntry = toEntry relsPath epochtime $ fromString rels'
169178 let archive = foldr addEntryToArchive refArchive $
170− contentEntry : relEntry : numEntry : styleEntry : docPropsEntry : imageEntries
179+ relsEntry : contentEntry : relEntry : numEntry : styleEntry : docPropsEntry : imageEntries
171180 return $ fromArchive archive
172181
173182styleToOpenXml :: Style -> [Element]