Docx writer: Create overrides per-image for media/ in ref docx.
This should be somewhat more robust and cover more types of images.
This commit is contained in:
parent
326d7fa8f8
commit
cbfde5cb50
1 changed files with 8 additions and 13 deletions
|
@ -170,6 +170,9 @@ writeDocx opts doc@(Pandoc meta _) = do
|
||||||
let mkImageOverride (_, imgpath, mbMimeType, _, _) =
|
let mkImageOverride (_, imgpath, mbMimeType, _, _) =
|
||||||
mkOverrideNode ("/word/" ++ imgpath,
|
mkOverrideNode ("/word/" ++ imgpath,
|
||||||
fromMaybe "application/octet-stream" mbMimeType)
|
fromMaybe "application/octet-stream" mbMimeType)
|
||||||
|
let mkMediaOverride imgpath = mkOverrideNode ('/':imgpath,
|
||||||
|
fromMaybe "application/octet-stream"
|
||||||
|
$ getMimeType imgpath)
|
||||||
let overrides = map mkOverrideNode (
|
let overrides = map mkOverrideNode (
|
||||||
[("/word/webSettings.xml",
|
[("/word/webSettings.xml",
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.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 ++
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")) headers ++
|
||||||
map (\x -> (maybe "" ("/word/" ++) $ extractTarget x,
|
map (\x -> (maybe "" ("/word/" ++) $ extractTarget x,
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++
|
||||||
map mkImageOverride imgs
|
map mkImageOverride imgs ++
|
||||||
let imageDefaults = map (\(x,y) -> mknode "Default"
|
map mkMediaOverride [ eRelativePath e | e <- zEntries refArchive
|
||||||
[("Extension",x),("ContentType",y)] ())
|
, "word/media/" `isPrefixOf` eRelativePath e ]
|
||||||
[("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")
|
|
||||||
]
|
|
||||||
let defaultnodes = [mknode "Default"
|
let defaultnodes = [mknode "Default"
|
||||||
[("Extension","xml"),("ContentType","application/xml")] (),
|
[("Extension","xml"),("ContentType","application/xml")] (),
|
||||||
mknode "Default"
|
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 contentTypesDoc = mknode "Types" [("xmlns","http://schemas.openxmlformats.org/package/2006/content-types")] $ defaultnodes ++ overrides
|
||||||
let contentTypesEntry = toEntry "[Content_Types].xml" epochtime
|
let contentTypesEntry = toEntry "[Content_Types].xml" epochtime
|
||||||
$ renderXml contentTypesDoc
|
$ renderXml contentTypesDoc
|
||||||
|
|
Loading…
Reference in a new issue