Skip to content

Commit

Permalink
Read image size of Inkscape SVGs (#3580)
Browse files Browse the repository at this point in the history
  • Loading branch information
schrieveslaach authored and jgm committed Apr 16, 2017
1 parent 56dddcc commit 1c8683f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Text/Pandoc/ImageSize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ imageType img = case B.take 4 img of
"%PDF" -> return Pdf
"<svg" -> return Svg
"<?xm"
| "<svg " == (B.take 5 $ last $ B.groupBy openingTag $ B.drop 7 img)
| findSvgTag img
-> return Svg
"%!PS"
| (B.take 4 $ B.drop 1 $ B.dropWhile (/=' ') img) == "EPSF"
-> return Eps
_ -> mzero
where
-- B.groupBy openingTag matches first "<svg" or "<html" but not "<!--"
openingTag x y = x == '<' && y /= '!'

findSvgTag :: ByteString -> Bool
findSvgTag img = B.null $ snd (B.breakSubstring img "<svg")

imageSize :: WriterOptions -> ByteString -> Either String ImageSize
imageSize opts img =
Expand Down

0 comments on commit 1c8683f

Please sign in to comment.