aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschrieveslaach <schrieveslaach@online.de>2017-04-16 19:39:24 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-16 19:39:24 +0200
commit1c8683f205c6e0b028dd62a13936d9a9f6124270 (patch)
treeecbe638950c746a5c469e176646ec97a84ae2ac0 /src
parent56dddcc3f556217a3354aff2e887b0ba4714f369 (diff)
downloadpandoc-1c8683f205c6e0b028dd62a13936d9a9f6124270.tar.gz
Read image size of Inkscape SVGs (#3580)
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/ImageSize.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 5cede7083..8b2d577a9 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -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 =