packages feed

diagrams-input 0.1.2 → 0.1.3

raw patch · 3 files changed

+13/−2 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Diagrams.SVG.ReadSVG: readSVGLBS :: (V b ~ V2, N b ~ n, RealFloat n, Renderable (Path V2 n) b, Renderable (DImage n Embedded) b, Typeable b, Typeable n, Show n, Read n, n ~ Place, Renderable (Text n) b, MonadThrow m) => ByteString -> m (Diagram b)

Files

CHANGELOG.md view
@@ -1,7 +1,10 @@-# v0.1.2 (14 June 2023)+# v0.1.3 (20 June 2023)  - Add new function `readSVGLBS` to read an SVG directly from a lazy   `ByteString` (thanks to Igor Moreno)++# v0.1.2 (14 June 2023)+ - Fix parsing bug that was causing some paths to be read   incorrectly ([#17](https://github.com/diagrams/diagrams-input/issues/17)) - Test with GHC 9.6
diagrams-input.cabal view
@@ -1,5 +1,5 @@ Name:                diagrams-input-Version:             0.1.2+Version:             0.1.3 Synopsis:            Parse raster and SVG files for diagrams Description:         Parse raster and SVG images for the diagrams DSL. License:             BSD3
src/Diagrams/SVG/ReadSVG.hs view
@@ -18,6 +18,7 @@     (     -- * Main functions       readSVGFile+    , readSVGLBS     , preserveAspectRatio     , nodes     , insertRefs@@ -67,6 +68,7 @@ import qualified Data.Attoparsec.Text as AT import qualified Data.Attoparsec.ByteString as ABS import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as LB import qualified Data.ByteString.Base64 as Base64 import           Data.Conduit import qualified Data.Conduit.List as CL@@ -132,6 +134,12 @@   where     catchAny :: IO a -> (SomeException -> IO a) -> IO a     catchAny = Control.Exception.catch++-- | Read SVG from a Lazy ByteString and turn it into a diagram.+readSVGLBS :: (V b ~ V2, N b ~ n, RealFloat n, Renderable (Path V2 n) b, Renderable (DImage n Embedded) b,+                Typeable b, Typeable n, Show n, Read n, n ~ Place, Renderable (TT.Text n) b, MonadThrow m)+            => LB.ByteString -> m (Diagram b)+readSVGLBS bs = runConduit $ diagram <$> (parseLBS def bs .| force "error in parseSVG: " parseSVG)  diagram :: (RealFloat n, V b ~ V2, n ~ N b, Typeable n, Read n, n ~ Place) => Tag b n -> Diagram b diagram tr = (insertRefs ((nmap,cssmap,expandedGradMap),(0,0,100,100)) tr) # scaleY (-1) # initialStyles