From c75740e22ce35165108e020be174ebe9f35ea667 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 16 Feb 2018 13:45:15 -0800 Subject: Make image size detection for PDFs more robust. See #4322. --- src/Text/Pandoc/ImageSize.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs index f21284dac..1d6db8dfa 100644 --- a/src/Text/Pandoc/ImageSize.hs +++ b/src/Text/Pandoc/ImageSize.hs @@ -283,8 +283,10 @@ pdfSize img = "/MediaBox" `B.isPrefixOf` l)) (B.lines img) of (x:_) | "/MediaBox" `B.isPrefixOf` x - -> case B.words $ B.filter (\c -> c /= '[' && c /= ']') - $ B.drop 10 x of + -> case B.words . B.takeWhile (/=']') + . B.drop 1 + . B.dropWhile (/='[') + $ x of [x1, y1, x2, y2] -> do x1' <- safeRead $ B.unpack x1 x2' <- safeRead $ B.unpack x2 -- cgit v1.2.3