git.iko.soy/typeable/pandoc
on master help sign in
imageSize interface change

`imageSize img` is now `imageSize opts img`

commit3f6b50e525255feda59ba44d4e094766bd87e0a9 authormb21 <mb21@users.noreply.github.com> dateWed 22 Feb 2017, 14:38 (10 years ago) parentb312ac6
5 files changed+9−10
src/Text/Pandoc/ImageSize.hs+5−6 src/Text/Pandoc/Writers/Docx.hs+1−1 src/Text/Pandoc/Writers/ICML.hs+1−1 src/Text/Pandoc/Writers/ODT.hs+1−1 src/Text/Pandoc/Writers/RTF.hs+1−1
src/Text/Pandoc/ImageSize.hs+5−6
@@ -115,13 +115,13 @@ imageType img = case B.take 4 img of
115115 -- B.groupBy openingTag matches first "<svg" or "<html" but not "<!--"
116116 openingTag x y = x == '<' && y /= '!'
117117
118−imageSize :: ByteString -> Either String ImageSize
119−imageSize img =
118+imageSize :: WriterOptions -> ByteString -> Either String ImageSize
119+imageSize opts img =
120120 case imageType img of
121121 Just Png -> mbToEither "could not determine PNG size" $ pngSize img
122122 Just Gif -> mbToEither "could not determine GIF size" $ gifSize img
123123 Just Jpeg -> jpegSize img
124− Just Svg -> mbToEither "could not determine SVG size" $ svgSize img
124+ Just Svg -> mbToEither "could not determine SVG size" $ svgSize opts img
125125 Just Eps -> mbToEither "could not determine EPS size" $ epsSize img
126126 Just Pdf -> Left "could not determine PDF size" -- TODO
127127 Nothing -> Left "could not determine image type"
@@ -286,10 +286,9 @@ gifSize img = do
286286 }
287287 _ -> Nothing -- "GIF parse error"
288288
289−svgSize :: ByteString -> Maybe ImageSize
290−svgSize img = do
289+svgSize :: WriterOptions -> ByteString -> Maybe ImageSize
290+svgSize opts img = do
291291 doc <- Xml.parseXMLDoc $ UTF8.toString img
292− let opts = def --TODO: use proper opts instead of def, which simply contains dpi=72
293292 let dpi = fromIntegral $ writerDpi opts
294293 let dirToInt dir = do
295294 dim <- Xml.findAttrBy (== Xml.QName dir Nothing Nothing) doc >>= lengthToDim
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -1184,7 +1184,7 @@ inlineToOpenXML' opts (Image attr alt (src, title)) = do
11841184 Right (img, mt) -> do
11851185 ident <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
11861186 let (xpt,ypt) = desiredSizeInPoints opts attr
1187− (either (const def) id (imageSize img))
1187+ (either (const def) id (imageSize opts img))
11881188 -- 12700 emu = 1 pt
11891189 let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700) (pageWidth * 12700)
11901190 let cNvPicPr = mknode "pic:cNvPicPr" [] $
src/Text/Pandoc/Writers/ICML.hs+1−1
@@ -546,7 +546,7 @@ imageICML opts style attr (src, _) = do
546546 report $ CouldNotFetchResource src ""
547547 return def
548548 Right (img, _) -> do
549− case imageSize img of
549+ case imageSize opts img of
550550 Right size -> return size
551551 Left msg -> do
552552 report $ CouldNotDetermineImageSize src msg
src/Text/Pandoc/Writers/ODT.hs+1−1
@@ -153,7 +153,7 @@ transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = do
153153 report $ CouldNotFetchResource src ""
154154 return $ Emph lab
155155 Right (img, mbMimeType) -> do
156− (ptX, ptY) <- case imageSize img of
156+ (ptX, ptY) <- case imageSize opts img of
157157 Right s -> return $ sizeInPoints s
158158 Left msg -> do
159159 report $ CouldNotDetermineImageSize src msg
src/Text/Pandoc/Writers/RTF.hs+1−1
@@ -63,7 +63,7 @@ rtfEmbedImage opts x@(Image attr _ (src,_)) = do
6363 "image/jpeg" -> return "\\jpegblip"
6464 "image/png" -> return "\\pngblip"
6565 _ -> throwError $ PandocSomeError "Unknown file type"
66− sizeSpec <- case imageSize imgdata of
66+ sizeSpec <- case imageSize opts imgdata of
6767 Left msg -> do
6868 report $ CouldNotDetermineImageSize src msg
6969 return ""