aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorricharddavis <richard.lee.davis@gmail.com>2019-03-21 09:43:56 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-03-21 10:43:56 -0600
commit567a43ace322bb8198a75954fef97e1cc91015a1 (patch)
tree32b97221dbe3c7c749fd0774d1c8653b9478d84e
parent66e5f0ff8de0f968d475f5135e0d9362690f2a0a (diff)
downloadpandoc-567a43ace322bb8198a75954fef97e1cc91015a1.tar.gz
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.
-rw-r--r--src/Text/Pandoc/ImageSize.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index c5289bbc2..afbba9b8b 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -278,13 +278,16 @@ pPdfSize = do
A.skipWhile (/='/')
A.char8 '/'
(do A.string "MediaBox"
+ A.skipSpace
A.char8 '['
+ A.skipSpace
[x1,y1,x2,y2] <- A.count 4 $ do
- A.skipWhile (==' ')
+ A.skipSpace
raw <- A.many1 $ A.satisfy (\c -> isDigit c || c == '.')
case safeRead raw of
Just (r :: Double) -> return $ floor r
Nothing -> mzero
+ A.skipSpace
A.char8 ']'
return $ ImageSize{
pxX = x2 - x1