git.iko.soy/typeable/pandoc
on master help sign in
Read image size of Inkscape SVGs (#3580)
commit1c8683f205c6e0b028dd62a13936d9a9f6124270 authorschrieveslaach <schrieveslaach@online.de> dateSun 16 Apr 2017, 19:39 (10 years ago) parent56dddcc
1 file changed+4−4
src/Text/Pandoc/ImageSize.hs+4−4
src/Text/Pandoc/ImageSize.hs+4−4
@@ -108,15 +108,15 @@ imageType img = case B.take 4 img of
108108 "%PDF" -> return Pdf
109109 "<svg" -> return Svg
110110 "<?xm"
111− | "<svg " == (B.take 5 $ last $ B.groupBy openingTag $ B.drop 7 img)
111+ | findSvgTag img
112112 -> return Svg
113113 "%!PS"
114114 | (B.take 4 $ B.drop 1 $ B.dropWhile (/=' ') img) == "EPSF"
115115 -> return Eps
116116 _ -> mzero
117− where
118− -- B.groupBy openingTag matches first "<svg" or "<html" but not "<!--"
119− openingTag x y = x == '<' && y /= '!'
117+
118+findSvgTag :: ByteString -> Bool
119+findSvgTag img = B.null $ snd (B.breakSubstring img "<svg")
120120
121121imageSize :: WriterOptions -> ByteString -> Either String ImageSize
122122imageSize opts img =