diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-06-02 20:39:27 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-06-02 20:39:27 -0700 |
commit | cbfde5cb50a461995a8b60d148615b5a72159f3d (patch) | |
tree | 905b4ed8d7faec311f5f9db97ea91bdcad2203b0 /src/Text | |
parent | 326d7fa8f89f9a4b74042bf4cbb04931e26c8d8d (diff) | |
download | pandoc-cbfde5cb50a461995a8b60d148615b5a72159f3d.tar.gz |
Docx writer: Create overrides per-image for media/ in ref docx.
This should be somewhat more robust and cover more types
of images.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 1e37b5515..e630c5094 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -170,6 +170,9 @@ writeDocx opts doc@(Pandoc meta _) = do let mkImageOverride (_, imgpath, mbMimeType, _, _) = mkOverrideNode ("/word/" ++ imgpath, fromMaybe "application/octet-stream" mbMimeType) + let mkMediaOverride imgpath = mkOverrideNode ('/':imgpath, + fromMaybe "application/octet-stream" + $ getMimeType imgpath) let overrides = map mkOverrideNode ( [("/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml") @@ -196,22 +199,14 @@ writeDocx opts doc@(Pandoc meta _) = do "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")) headers ++ map (\x -> (maybe "" ("/word/" ++) $ extractTarget x, "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++ - map mkImageOverride imgs - let imageDefaults = map (\(x,y) -> mknode "Default" - [("Extension",x),("ContentType",y)] ()) - [("jpg","image/jpeg") - ,("jpeg","image/jpeg") - ,("png","image/png") - ,("svg","image/svg+xml") - ,("tif","image/tiff") - ,("tiff","image/tiff") - ,("bmp","image/x-ms-bmp") - ,("gif","image/gif") - ] + map mkImageOverride imgs ++ + map mkMediaOverride [ eRelativePath e | e <- zEntries refArchive + , "word/media/" `isPrefixOf` eRelativePath e ] + let defaultnodes = [mknode "Default" [("Extension","xml"),("ContentType","application/xml")] (), mknode "Default" - [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] ++ imageDefaults + [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] let contentTypesDoc = mknode "Types" [("xmlns","http://schemas.openxmlformats.org/package/2006/content-types")] $ defaultnodes ++ overrides let contentTypesEntry = toEntry "[Content_Types].xml" epochtime $ renderXml contentTypesDoc |