git.iko.soy/typeable/pandoc
on master help sign in
ODT writer: calculate aspect ratio for percentage-sized images (#3478)

closes #3239

commitd0fc2f15737e21e257cdb22087373d15398e46c2 authorMauro Bieg <mb21@users.noreply.github.com> dateWed 1 Mar 2017, 12:13 (10 years ago) parentd1b50a6
2 files changed+2−4
src/Text/Pandoc/Writers/ODT.hs+2−2 src/Text/Pandoc/Writers/OpenDocument.hs−2
src/Text/Pandoc/Writers/ODT.hs+2−2
@@ -156,8 +156,8 @@ transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = catchError
156156 let dims =
157157 case (getDim Width, getDim Height) of
158158 (Just w, Just h) -> [("width", show w), ("height", show h)]
159− (Just w@(Percent _), Nothing) -> [("width", show w), ("style:rel-height", "scale")]
160− (Nothing, Just h@(Percent _)) -> [("style:rel-width", "scale"), ("height", show h)]
159+ (Just w@(Percent p), Nothing) -> [("width", show w), ("height", show (p / ratio) ++ "%")]
160+ (Nothing, Just h@(Percent p)) -> [("width", show (p * ratio) ++ "%"), ("height", show h)]
161161 (Just w@(Inch i), Nothing) -> [("width", show w), ("height", show (i / ratio) ++ "in")]
162162 (Nothing, Just h@(Inch i)) -> [("width", show (i * ratio) ++ "in"), ("height", show h)]
163163 _ -> [("width", show ptX ++ "pt"), ("height", show ptY ++ "pt")]
src/Text/Pandoc/Writers/OpenDocument.hs−2
@@ -476,8 +476,6 @@ inlineToOpenDocument o ils
476476 let getDims [] = []
477477 getDims (("width", w) :xs) = ("svg:width", w) : getDims xs
478478 getDims (("height", h):xs) = ("svg:height", h) : getDims xs
479− getDims (x@("style:rel-width", _) :xs) = x : getDims xs
480− getDims (x@("style:rel-height", _):xs) = x : getDims xs
481479 getDims (_:xs) = getDims xs
482480 return $ inTags False "draw:frame"
483481 (("draw:name", "img" ++ show id') : getDims kvs) $