git.iko.soy/typeable/pandoc
on master help sign in
Improve pdfSize in ImageSize by ignoring all whitespace in /MediaBox command (#5383)

This fix ignores all whitespace in the PDF /MediaBox line so that a wider range of PDF sizes can be read. This improves fix to #4322.

commit567a43ace322bb8198a75954fef97e1cc91015a1 authorricharddavis <richard.lee.davis@gmail.com> dateThu 21 Mar 2019, 09:43 (8 years ago) parent66e5f0f
1 file changed+4−1
src/Text/Pandoc/ImageSize.hs+4−1
src/Text/Pandoc/ImageSize.hs+4−1
@@ -278,13 +278,16 @@ pPdfSize = do
278278 A.skipWhile (/='/')
279279 A.char8 '/'
280280 (do A.string "MediaBox"
281+ A.skipSpace
281282 A.char8 '['
283+ A.skipSpace
282284 [x1,y1,x2,y2] <- A.count 4 $ do
283− A.skipWhile (==' ')
285+ A.skipSpace
284286 raw <- A.many1 $ A.satisfy (\c -> isDigit c || c == '.')
285287 case safeRead raw of
286288 Just (r :: Double) -> return $ floor r
287289 Nothing -> mzero
290+ A.skipSpace
288291 A.char8 ']'
289292 return $ ImageSize{
290293 pxX = x2 - x1