{-# LANGUAGE ConstraintKinds, DeriveDataTypeable, ExistentialQuantification, FlexibleContexts, FlexibleInstances, GADTs,
             MultiParamTypeClasses, NoMonomorphismRestriction, OverloadedStrings, TypeFamilies, UndecidableInstances #-}

-------------------------------------------------------------------
-- |
-- Module     : Diagrams.SVG.ReadSVG
-- Copyright  : (c) 2015 Tillmann Vogt <tillk.vogt@googlemail.com>
-- License    :  BSD-style (see LICENSE)
-- Maintainer :  diagrams-discuss@googlegroups.com
--
-- Maintainer : diagrams-discuss@googlegroups.com
-- Stability  : stable
-- Portability: portable

-------------------------------------------------------------------

module Diagrams.SVG.ReadSVG
    (
    -- * Main functions
      readSVGFile
    , readSVGLBS
    , preserveAspectRatio
    , nodes
    , insertRefs
    , PreserveAR(..)
    , AlignSVG(..)
    , Place(..)
    , MeetOrSlice(..)
    , InputConstraints(..)
    -- * Parsing of basic structure tags
    , parseSVG
    , parseG
    , parseDefs
    , parseSymbol
    , parseUse
    , parseSwitch
    , parseDesc
    , parseTitle
--    , parseMetaData
    -- * Parsing of basic shape tags
    , parseRect
    , parseCircle
    , parseEllipse
    , parseLine
    , parsePolyLine
    , parsePolygon
    , parsePath
    -- * Parsing of Gradient tags
    , parseLinearGradient
    , parseRadialGradient
    , parseSet
    , parseStop
    -- * Parsing of other tags
    , parseClipPath
    , parsePattern
    , parseFilter
    , parseImage
    , parseText
    -- * Parsing data uri in <image>
    , dataUriToImage
    ) where

import           Codec.Picture
import           Control.Monad.IO.Class
import           Control.Monad.Trans.Resource
import           Control.Monad.Trans.Class
import           Data.Either.Combinators
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
import qualified Data.Colour
import qualified Data.Conduit.List as C
import qualified Data.HashMap.Strict as H
import           Data.Maybe (fromJust, fromMaybe, isJust)
import qualified Data.Text as T
import           Data.Text(Text(..))
import           Data.Text.Encoding
import           Data.Typeable (Typeable)
import           Data.XML.Types
import           Diagrams.Attributes
import           Diagrams.Prelude
import           Diagrams.TwoD.Ellipse
import           Diagrams.TwoD.Path (isInsideEvenOdd)
import           Diagrams.TwoD.Size
import           Diagrams.TwoD.Types
import qualified Diagrams.TwoD.Text as TT
import           Diagrams.SVG.Arguments
import           Diagrams.SVG.Attributes
import           Diagrams.SVG.Fonts.ReadFont
import           Diagrams.SVG.Path (commands, commandsToPaths, PathCommand(..))
import           Diagrams.SVG.Tree
import           Filesystem.Path (FilePath(..), extension)
import           Filesystem.Path.CurrentOS (encodeString)
import           Prelude hiding (FilePath)
import           Text.XML.Stream.Parse hiding (parseText)
import           Text.CSS.Parse (parseBlocks)
import           Control.Exception ( SomeException, catch )

import           Debug.Trace
--------------------------------------------------------------------------------------
-- | Main library function
-- 
-- @
-- \{-\# LANGUAGE OverloadedStrings \#-\}
--
-- module Main where
-- import Diagrams.SVG.ReadSVG
-- import Diagrams.Prelude
-- import Diagrams.Backend.SVG.CmdLine
-- import System.Environment
-- import Filesystem.Path.CurrentOS
-- import Diagrams.SVG.Attributes (PreserveAR(..), AlignSVG(..), Place(..), MeetOrSlice(..))
--
-- main = do
--    diagramFromSVG :: Either String (Diagram B) <- readSVGFile \"svgs/web.svg\"
--    case diagramFromSVG of
--      Left msg      -> error $ \"readSVGFile returned: \" <> msg
--      Right diagram -> mainWith $ diagram
-- @
--
readSVGFile :: (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)
             => Filesystem.Path.FilePath -> IO (Either String (Diagram b))
readSVGFile :: forall b n.
(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) =>
FilePath -> IO (Either String (Diagram b))
readSVGFile FilePath
fp = if (FilePath -> Maybe Text
extension FilePath
fp) forall a. Eq a => a -> a -> Bool
== (forall a. a -> Maybe a
Just Text
"svg")
    then forall a. IO a -> (SomeException -> IO a) -> IO a
catchAny (forall (m :: * -> *) a. MonadUnliftIO m => ResourceT m a -> m a
runResourceT forall a b. (a -> b) -> a -> b
$ do
           Tag b (N b)
tree <- forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
runConduit forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i.
MonadResource m =>
ParseSettings -> String -> ConduitT i Event m ()
parseFile forall a. Default a => a
def (FilePath -> String
encodeString FilePath
fp) forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) a.
MonadThrow m =>
String -> m (Maybe a) -> m a
force String
"error in parseSVG: " forall (m :: * -> *) b n.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event Void m (Maybe (Tag b n))
parseSVG
           forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall n b.
(RealFloat n, V b ~ V2, n ~ N b, Typeable n, Read n, n ~ Place) =>
Tag b n -> Diagram b
diagram Tag b (N b)
tree)
         forall a b. (a -> b) -> a -> b
$ \SomeException
e -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ String
"error in parseFile: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show SomeException
e
     else forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left String
"Not a svg file"
  where
    catchAny :: IO a -> (SomeException -> IO a) -> IO a
    catchAny :: forall a. IO a -> (SomeException -> IO a) -> IO a
catchAny = forall e a. Exception e => IO a -> (e -> IO a) -> IO a
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 :: forall b n (m :: * -> *).
(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)
readSVGLBS ByteString
bs = forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
runConduit forall a b. (a -> b) -> a -> b
$ forall n b.
(RealFloat n, V b ~ V2, n ~ N b, Typeable n, Read n, n ~ Place) =>
Tag b n -> Diagram b
diagram forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (m :: * -> *) i.
MonadThrow m =>
ParseSettings -> ByteString -> ConduitT i Event m ()
parseLBS forall a. Default a => a
def ByteString
bs forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) a.
MonadThrow m =>
String -> m (Maybe a) -> m a
force String
"error in parseSVG: " forall (m :: * -> *) b n.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event Void m (Maybe (Tag b n))
parseSVG)

diagram :: (RealFloat n, V b ~ V2, n ~ N b, Typeable n, Read n, n ~ Place) => Tag b n -> Diagram b
diagram :: forall n b.
(RealFloat n, V b ~ V2, n ~ N b, Typeable n, Read n, n ~ Place) =>
Tag b n -> Diagram b
diagram Tag b n
tr = (forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Place ~ n) =>
(HashMaps b n, ViewBox n) -> Tag b n -> Diagram b
insertRefs ((HashMap Text (Tag b n)
nmap,HashMap Text Attrs
cssmap,GradientsMap n
expandedGradMap),(n
0,n
0,n
100,n
100)) Tag b n
tr) forall a b. a -> (a -> b) -> b
# forall (v :: * -> *) n t.
(InSpace v n t, R2 v, Fractional n, Transformable t) =>
n -> t -> t
scaleY (-Place
1) forall a b. a -> (a -> b) -> b
# forall {c}.
(V c ~ V2, Floating (N c), Typeable (N c), HasStyle c,
 Ord (N c)) =>
c -> c
initialStyles
  where
    (Nodelist b n
ns,CSSlist
css,Gradlist n
grad,Fontlist b n
fonts) = forall n b.
Maybe (ViewBox n)
-> (Nodelist b n, CSSlist, Gradlist n, Fontlist b n)
-> Tag b n
-> (Nodelist b n, CSSlist, Gradlist n, Fontlist b n)
nodes forall a. Maybe a
Nothing ([],[],[], []) Tag b n
tr
    nmap :: HashMap Text (Tag b n)
nmap    = forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
H.fromList Nodelist b n
ns -- needed because of the use-tag and clipPath
    cssmap :: HashMap Text Attrs
cssmap  = forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
H.fromList CSSlist
css -- CSS inside the <defs> tag
    gradmap :: GradientsMap n
gradmap = forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
H.fromList Gradlist n
grad
    expandedGradMap :: GradientsMap n
expandedGradMap = forall n. GradientsMap n -> GradientsMap n
expandGradMap GradientsMap n
gradmap


-- | Read font data from font file, and compute its outline map.
--
{-
loadFont :: (Read n, RealFloat n) => FilePath -> IO (Either String (PreparedFont n))
loadFont filename = if (extension fp) /= (Just "svg") then return $ Left "Not a svg file" else -- TODO All exceptions into left values
  runResourceT $ runEitherT $ do
    tree <- lift (parseFile def fp $$ force "error in parseSVG" parseSVG)
    let fontData = font tree
    case fontData of Left s -> return (Left s)
                     Right s -> do let (font, errs) = prepareFont fontData
                                   sequence_ [ putStrLn ("error parsing character '" ++ ch ++ "': " ++ err)
                                             | (ch, err) <- Map.toList errs
                                             ]
                                   return font

font tr = fonts
  where (ns,css,grad,fonts) = nodes Nothing ([],[],[], []) tr
-}
-------------------------------------------------------------------------------------
-- Basic SVG structure

tagName :: Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
name = forall (m :: * -> *) a b o c.
MonadThrow m =>
NameMatcher a
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tag' ((Name -> Bool) -> NameMatcher Name
Text.XML.Stream.Parse.matching (forall a. Eq a => a -> a -> Bool
== Name
name))

class (V b ~ V2, N b ~ n, RealFloat n, Renderable (Path V2 n) b, Typeable n, Typeable b, Show n,
       Renderable (DImage n Embedded) b) => InputConstraints b n

instance (V b ~ V2, N b ~ n, RealFloat n, Renderable (Path V2 n) b, Typeable n, Typeable b, Show n,
          Renderable (DImage n Embedded) b) => InputConstraints b n

-- | Parse \<svg\>, see <http://www.w3.org/TR/SVG/struct.html#SVGElement>
parseSVG :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) 
          => ConduitT Event Void m (Maybe (Tag b n))
parseSVG :: forall (m :: * -> *) b n.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event Void m (Maybe (Tag b n))
parseSVG = forall (m :: * -> *) a b o c.
MonadThrow m =>
NameMatcher a
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tag' ([Name] -> NameMatcher Name
Text.XML.Stream.Parse.anyOf [Name
"svg", Name
"{http://www.w3.org/2000/svg}svg"]) AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, NameSpaces, Maybe Text)
svgAttrs forall a b. (a -> b) -> a -> b
$
   \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h,Maybe Text
vb,Maybe Text
ar,Maybe Text
zp,Maybe Text
ver,Maybe Text
baseprof,Maybe Text
cScripT,Maybe Text
cStyleT,NameSpaces
xmlns,Maybe Text
xml) ->
   do [Tag b n]
gs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent
      let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++ -- parse the style attribute (style="stop-color:#000000;stop-opacity:0.8")
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++ -- presentation attributes: stop-color="#000000" stop-opacity="0.8"
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"svg" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      let pw :: Place
pw = if (forall a. Maybe a -> Bool
isJust Maybe Text
w) then forall n. RealFloat n => Text -> n
parseDouble forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
fromJust Maybe Text
w else Place
0
      let ph :: Place
ph = if (forall a. Maybe a -> Bool
isJust Maybe Text
h) then forall n. RealFloat n => Text -> n
parseDouble forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
fromJust Maybe Text
h else Place
0
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ -- Debug.Trace.trace ("@" ++ show vb ++ show (parseViewBox vb w h)) (
               forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
True (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                            (Place
pw,Place
ph)
                            (forall n.
RealFloat n =>
Maybe Text -> Maybe Text -> Maybe Text -> Maybe (ViewBox n)
parseViewBox Maybe Text
vb Maybe Text
w Maybe Text
h)
                            (Maybe Text -> Maybe PreserveAR
parsePreserveAR Maybe Text
ar)
                            (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st)
                            (forall a. [a] -> [a]
reverse [Tag b n]
gs)

svgContent :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) 
            => ConduitT Event Void m (Maybe (Tag b n))
svgContent :: forall (m :: * -> *) b n.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event Void m (Maybe (Tag b n))
svgContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose -- the likely most common are checked first
     [forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseG, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePath, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseCircle, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRect, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseEllipse, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolyLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolygon,
      forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseDefs, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseSymbol, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseUse, -- structural elements
      forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseClipPath, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePattern, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseImage, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, RealFloat n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseText, -- parseSwitch, parseSodipodi,
      forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
skipArbitraryTag] -- should always be last!
      -- parseDesc, parseMetaData, parseTitle] -- descriptive Elements

---------------------------------------------------------------------------
-- | Parse \<g\>, see <http://www.w3.org/TR/SVG/struct.html#GElement>
parseG :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) 
        => forall o. ConduitT Event o m (Maybe (Tag b n))
parseG :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseG = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}g" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text)
gAttrs
   forall a b. (a -> b) -> a -> b
$ \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr) ->
   do [Tag b n]
insideGs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent
      let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"g" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
True (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                            (Place
0, Place
0)
                            forall a. Maybe a
Nothing
                            forall a. Maybe a
Nothing
                            (\(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps -> (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
tr)) )
                            (forall a. [a] -> [a]
reverse [Tag b n]
insideGs)

gContent :: (MonadThrow m, InputConstraints b n, Show n, Read n, Renderable (TT.Text n) b) 
          => forall o. ConduitT Event o m (Maybe (Tag b n))
gContent :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose -- the likely most common are checked first
     [forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePath, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseG, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRect, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseCircle, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseEllipse, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolyLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolygon,
      forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseUse, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseSymbol, forall (m :: * -> *) n b o.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseStyle, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseDefs, -- structural elements
      forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseClipPath, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLinearGradient, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRadialGradient, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseImage, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, RealFloat n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseText, -- parseFont,
      forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
skipArbitraryTag] -- -- should always be last!
--      parseFilter, parsePattern, parseSwitch, parsePerspective,
--      parseDesc, parseMetaData, parseTitle, parsePathEffect] -- descriptive Elements

---------------------------------------------------------------------------
-- | Parse \<defs\>, see <http://www.w3.org/TR/SVG/struct.html#DefsElement>
parseDefs :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) 
           => forall o. ConduitT Event o m (Maybe (Tag b n))
parseDefs :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseDefs = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}defs" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text)
gAttrs forall a b. (a -> b) -> a -> b
$
   \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr) ->
   do [Tag b n]
insideDefs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent
      let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA PresentationAttributes
pa (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"defs" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
False (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                             (Place
0, Place
0)
                             forall a. Maybe a
Nothing
                             forall a. Maybe a
Nothing
                             ( (forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
tr)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st) )
                             (forall a. [a] -> [a]
reverse [Tag b n]
insideDefs)

---------------------------------------------------------------------------
-- | Parse \<defs\>, see <http://www.w3.org/TR/SVG/struct.html#DefsElement>
-- e.g.
--  <style type="text/css">
--   <![CDATA[
--    .fil0 {fill:#FEFEFE}
--    .fil1 {fill:#3A73B8}
--   ]]>
--  </style>
parseStyle :: (MonadThrow m, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseStyle :: forall (m :: * -> *) n b o.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseStyle = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}style" AttrParser (CoreAttributes, Maybe Text, Maybe Text, Maybe Text)
sAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,Maybe Text
type_,Maybe Text
media,Maybe Text
title) ->
   do Text
insideStyle <- forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
      let blocks :: Either String CSSlist
blocks = Text -> Either String CSSlist
parseBlocks Text
insideStyle -- parseBlocks :: Text -> Either String [CssBlock]
      let cssBlocks :: CSSlist
cssBlocks = case Either String CSSlist
blocks of
                   Left String
err -> []
                   Right CSSlist
st -> CSSlist
st
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. CSSlist -> Tag b n
StyleTag CSSlist
cssBlocks -- type CssBlock = (Text, [(Text, Text)]) = (selector, [(attribute, value)])

-----------------------------------------------------------------------------------
-- | Parse \<symbol\>, see <http://www.w3.org/TR/SVG/struct.html#SymbolElement>
parseSymbol :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) 
             => forall o. ConduitT Event o m (Maybe (Tag b n))
parseSymbol :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
parseSymbol = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}symbol" AttrParser
  (CoreAttributes, GraphicalEventAttributes, PresentationAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
symbolAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
ar,Maybe Text
viewbox) ->
   do [Tag b n]
insideSym <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent
      let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"symbol" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
False (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                             (Place
0, Place
0)
                             (forall n.
RealFloat n =>
Maybe Text -> Maybe Text -> Maybe Text -> Maybe (ViewBox n)
parseViewBox Maybe Text
viewbox forall a. Maybe a
Nothing forall a. Maybe a
Nothing)
                             (Maybe Text -> Maybe PreserveAR
parsePreserveAR Maybe Text
ar)
                             (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st)
                             (forall a. [a] -> [a]
reverse [Tag b n]
insideSym)

-----------------------------------------------------------------------------------
-- | Parse \<use\>, see <http://www.w3.org/TR/SVG/struct.html#UseElement>
parseUse :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Typeable n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseUse :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseUse = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}use" AttrParser
  (CoreAttributes, ConditionalProcessingAttributes,
   GraphicalEventAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text)
useAttrs
   forall a b. (a -> b) -> a -> b
$ \(CoreAttributes
ca,ConditionalProcessingAttributes
cpa,GraphicalEventAttributes
gea,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h) ->
   do -- insideUse <- many useContent
      let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"use" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      let path :: (n, n, n, n) -> Path V2 n
path (n
minx,n
miny,n
vbW,n
vbH) = forall n t. (InSpace V2 n t, TrailLike t) => n -> n -> t
rect (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
vbW) n
0 Maybe Text
w)  (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
vbH) n
0 Maybe Text
h)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b -> Diagram b)
-> Tag b n
Reference (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                         (Maybe Text -> Maybe Text
Diagrams.SVG.Attributes.fragment forall a b. (a -> b) -> a -> b
$ XlinkAttributes -> Maybe Text
xlinkHref XlinkAttributes
xlink)
                         (n, n, n, n) -> Path V2 n
path
                         (forall {c} {t}.
(V c ~ V2, Transformable c, RealFloat (N c), Additive (V c),
 R2 (V c), HasStyle c, Typeable (N c)) =>
Maybe Text
-> Maybe Text
-> Maybe Text
-> (t -> [SVGStyle (N c) Place])
-> (t, (N c, N c, N c, N c))
-> c
-> c
f Maybe Text
tr Maybe Text
x Maybe Text
y (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st) -- f gets supplied with the missing maps an viewbox when evaluating the Tag-tree
  where -- f :: Maybe Text -> Maybe Text -> Maybe Text -> (HashMaps b n -> [SVGStyle n a]) 
        -- -> (HashMaps b n, (n,n,n,n)) -> Diagram b -> Diagram b
        f :: Maybe Text
-> Maybe Text
-> Maybe Text
-> (t -> [SVGStyle (N c) Place])
-> (t, (N c, N c, N c, N c))
-> c
-> c
f Maybe Text
tr Maybe Text
x Maybe Text
y t -> [SVGStyle (N c) Place]
st (t
maps,(N c
minx,N c
miny,N c
vbW,N c
vbH)) = (forall t. Transformable t => Vn t -> t -> t
translate (forall n. (n, n) -> V2 n
r2 (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (N c
vbW, N c
minx) N c
0 Maybe Text
x, 
                                                                 forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (N c
vbH, N c
miny) N c
0 Maybe Text
y))) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
                                                 (forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
tr)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG t -> [SVGStyle (N c) Place]
st t
maps)

useContent :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
useContent :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
useContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseDesc,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseTitle] -- descriptive elements

--------------------------------------------------------------------------------------
-- | Parse \<switch\>, see <http://www.w3.org/TR/SVG/struct.html#SwitchElement>
parseSwitch :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseSwitch :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseSwitch = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}switch" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text)
switchAttrs
   forall a b. (a -> b) -> a -> b
$ \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr) ->
   do -- insideSwitch <- many switchContent
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- switchContent :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
switchContent :: ConduitT Event o m (Maybe (Tag b (N b)))
switchContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePath, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRect, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseCircle, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseEllipse, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolyLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolygon]

-----------------------------------------------------------------------------------
-- | Parse \<rect\>,  see <http://www.w3.org/TR/SVG11/shapes.html#RectElement>
parseRect :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseRect :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRect = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}rect" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
rectAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
ar,Maybe Text
tr,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h,Maybe Text
rx,Maybe Text
ry) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"rect" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let rRect :: N t -> N t -> N t -> N t -> t
rRect N t
pw N t
ph N t
prx N t
pry | N t
prx forall a. Eq a => a -> a -> Bool
== N t
0 Bool -> Bool -> Bool
&& N t
pry forall a. Eq a => a -> a -> Bool
== N t
0 = forall n t. (InSpace V2 n t, TrailLike t) => n -> n -> t
rect N t
pw N t
ph
                            | Bool
otherwise = forall n t.
(InSpace V2 n t, TrailLike t, RealFloat n) =>
n -> n -> n -> t
roundedRect N t
pw N t
ph (if N t
prx forall a. Eq a => a -> a -> Bool
== N t
0 then N t
pry else N t
prx)
    let path :: (n, n, n, n) -> Path V2 n
path (n
minx,n
miny,n
vbW,n
vbH) = (forall {t}.
(V t ~ V2, TrailLike t, RealFloat (N t)) =>
N t -> N t -> N t -> N t -> t
rRect (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
vbW) n
0 Maybe Text
w)  (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
vbH) n
0 Maybe Text
h)
                                          (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
vbW) n
0 Maybe Text
rx) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
vbH) n
0 Maybe Text
ry))
                                   # alignBL
                                   # applyTr (parseTr tr)
                                   # translate (r2 (p (minx,vbW) 0 x, p (miny,vbH) 0 y))
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,(n, n, n, n)
viewbox) = (n, n, n, n) -> Path V2 n
path (n, n, n, n)
viewbox forall a b. a -> (a -> b) -> b
# forall n t b.
(InSpace V2 n t, ToPath t, TypeableFloat n,
 Renderable (Path V2 n) b) =>
t -> QDiagram b V2 n Any
stroke forall a b. a -> (a -> b) -> b
# forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (n, n, n, n) -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f

---------------------------------------------------------------------------------------------------
-- | Parse \<circle\>,  see <http://www.w3.org/TR/SVG11/shapes.html#CircleElement>
parseCircle :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseCircle :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseCircle = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}circle" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
circleAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
r,Maybe Text
cx,Maybe Text
cy) -> do
    let -- st :: (RealFloat n, RealFloat a, Read a) => (HashMaps b n, ViewBox n) -> [SVGStyle n a]
        st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"circle" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let path :: (n, n, n, n) -> Path V2 n
path (n
minx,n
miny,n
w,n
h) = forall t n.
(TrailLike t, V t ~ V2, N t ~ n, Transformable t) =>
n -> t
circle (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
r) -- TODO: radius of a circle in percentages (relative to x?)
                               # applyTr (parseTr tr)
                               # translate (r2 (p (minx,w) 0 cx, p (miny,h) 0 cy))
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,(n, n, n, n)
viewbox) = (n, n, n, n) -> Path V2 n
path (n, n, n, n)
viewbox forall a b. a -> (a -> b) -> b
# forall n t b.
(InSpace V2 n t, ToPath t, TypeableFloat n,
 Renderable (Path V2 n) b) =>
t -> QDiagram b V2 n Any
stroke forall a b. a -> (a -> b) -> b
# forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (n, n, n, n) -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f

---------------------------------------------------------------------------------------------------
-- | Parse \<ellipse\>,  see <http://www.w3.org/TR/SVG11/shapes.html#EllipseElement>
parseEllipse :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseEllipse :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseEllipse = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}ellipse" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
ellipseAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
rx,Maybe Text
ry,Maybe Text
cx,Maybe Text
cy) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"ellipse" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let path :: (n, n, n, n) -> Path V2 n
path (n
minx,n
miny,n
w,n
h) = ((forall t n.
(TrailLike t, V t ~ V2, N t ~ n, Transformable t) =>
n -> n -> t
ellipseXY (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
rx) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
ry) ))
                               # applyTr (parseTr tr)
                               # translate (r2 (p (minx,w) 0 cx, p (miny,h) 0 cy))
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,(n, n, n, n)
viewbox) = (n, n, n, n) -> Path V2 n
path (n, n, n, n)
viewbox forall a b. a -> (a -> b) -> b
# forall n t b.
(InSpace V2 n t, ToPath t, TypeableFloat n,
 Renderable (Path V2 n) b) =>
t -> QDiagram b V2 n Any
stroke forall a b. a -> (a -> b) -> b
# forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (n, n, n, n) -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f

---------------------------------------------------------------------------------------------------
-- | Parse \<line\>,  see <http://www.w3.org/TR/SVG11/shapes.html#LineElement>
parseLine :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseLine :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLine = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}line" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
lineAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
x1,Maybe Text
y1,Maybe Text
x2,Maybe Text
y2) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"line" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let path :: (n, n, n, n) -> Path V2 n
path (n
minx,n
miny,n
w,n
h) = (forall t. TrailLike t => [Segment Closed (V t) (N t)] -> t
fromSegments [ forall (v :: * -> *) n. v n -> Segment Closed v n
straight (forall n. (n, n) -> V2 n
r2 ((forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
x2) forall a. Num a => a -> a -> a
- (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
x1), 
                                                             (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
y2) forall a. Num a => a -> a -> a
- (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
y1))) ])
                               # applyTr (parseTr tr)
                               # translate (r2 (p (minx,w) 0 x1, p (miny,h) 0 y1))
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,(n, n, n, n)
viewbox) = (n, n, n, n) -> Path V2 n
path (n, n, n, n)
viewbox forall a b. a -> (a -> b) -> b
# forall n t b.
(InSpace V2 n t, ToPath t, TypeableFloat n,
 Renderable (Path V2 n) b) =>
t -> QDiagram b V2 n Any
stroke
                                        # applyStyleSVG st maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (n, n, n, n) -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 (n, n, n, n))
-> QDiagram b V2 n Any
f

---------------------------------------------------------------------------------------------------
-- | Parse \<polyline\>,  see <http://www.w3.org/TR/SVG11/shapes.html#PolylineElement>
parsePolyLine :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parsePolyLine :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolyLine = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}polyline" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
polygonAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
points) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"polyline" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let ps :: [(n, n)]
ps = forall n. RealFloat n => Text -> [(n, n)]
parsePoints (forall a. HasCallStack => Maybe a -> a
fromJust Maybe Text
points)
    let path :: ViewBox n -> Path V2 n
path ViewBox n
viewbox = forall t. TrailLike t => [Point (V t) (N t)] -> t
fromVertices (forall a b. (a -> b) -> [a] -> [b]
map forall n. (n, n) -> P2 n
p2 [(n, n)]
ps) forall a b. a -> (a -> b) -> b
# forall t. Transformable t => Vn t -> t -> t
translate (forall n. (n, n) -> V2 n
r2 (forall a. [a] -> a
head [(n, n)]
ps))
                                                # applyTr (parseTr tr)

    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,ViewBox n
viewbox) = forall t. TrailLike t => [Point (V t) (N t)] -> t
fromVertices (forall a b. (a -> b) -> [a] -> [b]
map forall n. (n, n) -> P2 n
p2 [(n, n)]
ps) forall a b. a -> (a -> b) -> b
# forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Trail' Line V2 n -> QDiagram b V2 n Any
strokeLine
                                                    # translate (r2 (head ps))
                                                    # applyTr (parseTr tr)
                                                    # applyStyleSVG st maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) ViewBox n -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f

--------------------------------------------------------------------------------------------------
-- | Parse \<polygon\>,  see <http://www.w3.org/TR/SVG11/shapes.html#PolygonElement>
parsePolygon :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parsePolygon :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolygon = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}polygon" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
polygonAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
points) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"polygon" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let ps :: [(n, n)]
ps = forall n. RealFloat n => Text -> [(n, n)]
parsePoints (forall a. HasCallStack => Maybe a -> a
fromJust Maybe Text
points)
    let path :: ViewBox n -> Path V2 n
path ViewBox n
viewbox = forall t. TrailLike t => [Point (V t) (N t)] -> t
fromVertices (forall a b. (a -> b) -> [a] -> [b]
map forall n. (n, n) -> P2 n
p2 [(n, n)]
ps) forall a b. a -> (a -> b) -> b
# forall t. Transformable t => Vn t -> t -> t
translate (forall n. (n, n) -> V2 n
r2 (forall a. [a] -> a
head [(n, n)]
ps))
                                                # applyTr (parseTr tr)
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,ViewBox n
viewbox) = forall t. TrailLike t => [Point (V t) (N t)] -> t
fromVertices (forall a b. (a -> b) -> [a] -> [b]
map forall n. (n, n) -> P2 n
p2 [(n, n)]
ps) forall a b. a -> (a -> b) -> b
# forall (v :: * -> *) n. Trail' Line v n -> Trail' Loop v n
closeLine
                                                    # strokeLoop
                                                    # translate (r2 (head ps))
                                                    # applyTr (parseTr tr)
                                                    # applyStyleSVG st maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) ViewBox n -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f

--------------------------------------------------------------------------------------------------
-- | Parse \<path\>,  see <http://www.w3.org/TR/SVG11/paths.html#PathElement>
parsePath :: (MonadThrow m, InputConstraints b n, Show n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parsePath :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePath = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}path" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
pathAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
d,Maybe Text
pathLength) -> do
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"path" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    let path :: ViewBox n -> Path V2 n
path ViewBox n
viewbox = (forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ forall n. (RealFloat n, Show n) => [PathCommand n] -> [Path V2 n]
commandsToPaths forall a b. (a -> b) -> a -> b
$ forall n. (RealFloat n, Show n) => Maybe Text -> [PathCommand n]
commands Maybe Text
d) forall a b. a -> (a -> b) -> b
# forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
tr)
    let f :: ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps,ViewBox n
viewbox) = ViewBox n -> Path V2 n
path ViewBox n
viewbox forall a b. a -> (a -> b) -> b
# forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
Path V2 n -> QDiagram b V2 n Any
strokePath
                                        # applyStyleSVG st maps
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) ViewBox n -> Path V2 n
path ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n)),
 ViewBox n)
-> QDiagram b V2 n Any
f

-------------------------------------------------------------------------------------------------
-- | Parse \<clipPath\>, see <http://www.w3.org/TR/SVG/masking.html#ClipPathElement>
parseClipPath :: (MonadThrow m, InputConstraints b n, Show n, Read n, Renderable (TT.Text n) b) 
               => forall o. ConduitT Event o m (Maybe (Tag b n))
parseClipPath :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseClipPath = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}clipPath" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   PresentationAttributes, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
clipPathAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
ar,Maybe Text
viewbox) -> do
    [Tag b n]
insideClipPath <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
clipPathContent
    let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                   (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"clipPath" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
False (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                     (Place
0, Place
0)
                     (forall n.
RealFloat n =>
Maybe Text -> Maybe Text -> Maybe Text -> Maybe (ViewBox n)
parseViewBox Maybe Text
viewbox forall a. Maybe a
Nothing forall a. Maybe a
Nothing)
                     (Maybe Text -> Maybe PreserveAR
parsePreserveAR Maybe Text
ar)
                     (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st)
                     (forall a. [a] -> [a]
reverse [Tag b n]
insideClipPath)

clipPathContent :: (MonadThrow m, InputConstraints b n, Show n, Read n, Renderable (TT.Text n) b) 
                 => forall o. ConduitT Event o m (Maybe (Tag b n))
clipPathContent :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
clipPathContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRect, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseCircle, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseEllipse, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolyLine, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePath,
                          forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePolygon, forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, RealFloat n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseText, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseUse]

--------------------------------------------------------------------------------------
-- | Parse \<image\>, see <http://www.w3.org/TR/SVG/struct.html#ImageElement>
-- <image width="28" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAADCAYAAACAjW/aAAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH2AkMDx4ErQ9V0AAAAClJREFUGJVjYMACGhoa/jMwMPyH0kQDYvQxYpNsaGjAyibCQrL00dSHACypIHXUNrh3AAAAAElFTkSuQmCC" height="3"/>
parseImage :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Renderable (DImage (N b) Embedded) b,
              Typeable b, Typeable n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseImage :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseImage = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}image" AttrParser
  (CoreAttributes, ConditionalProcessingAttributes,
   GraphicalEventAttributes, XlinkAttributes, PresentationAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
imageAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,ConditionalProcessingAttributes
cpa,GraphicalEventAttributes
gea,XlinkAttributes
xlink,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
ar,Maybe Text
tr,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h) ->
  do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty (\(HashMaps b n
_,(n
minx,n
miny,n
vbW,n
vbH)) -> (forall b n.
(Metric (V b), Ord n, RealFloat n, N b ~ n, V2 ~ V b,
 Renderable (DImage n Embedded) b, Typeable b, Typeable n) =>
Maybe Text -> n -> n -> Diagram b
dataUriToImage (XlinkAttributes -> Maybe Text
xlinkHref XlinkAttributes
xlink) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
vbW) n
0 Maybe Text
w) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
vbH) n
0 Maybe Text
h))
                                           # alignBL
                                           # applyTr (parseTr tr)
                                           # translate (r2 (p (minx,vbW) 0 x, p (miny,vbH) 0 y)))
-- TODO aspect ratio

data ImageType = JPG | PNG | SVG

---------------------------------------------------------------------------------------------------
-- | Convert base64 encoded data in <image> to a Diagram b with JuicyPixels
--   input: "data:image/png;base64,..."
dataUriToImage :: (Metric (V b), Ord n, RealFloat n, N b ~ n, V2 ~ V b, Renderable (DImage n Embedded) b,
                  Typeable b, Typeable n) => Maybe Text -> n -> n -> Diagram b
dataUriToImage :: forall b n.
(Metric (V b), Ord n, RealFloat n, N b ~ n, V2 ~ V b,
 Renderable (DImage n Embedded) b, Typeable b, Typeable n) =>
Maybe Text -> n -> n -> Diagram b
dataUriToImage Maybe Text
_           n
0 n
h = forall a. Monoid a => a
mempty
dataUriToImage Maybe Text
_           n
w n
0 = forall a. Monoid a => a
mempty
dataUriToImage Maybe Text
Nothing     n
w n
h = forall a. Monoid a => a
mempty
dataUriToImage (Just Text
text) n
w n
h = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a b. a -> b -> a
const forall a. Monoid a => a
mempty) forall a. a -> a
id forall a b. (a -> b) -> a -> b
$ forall a. Parser a -> ByteString -> Either String a
ABS.parseOnly Parser ByteString (QDiagram b V2 n Any)
dataUri (Text -> ByteString
encodeUtf8 Text
text)
  where
    jpg :: Parser ByteString ImageType
jpg = do { ByteString -> Parser ByteString
ABS.string ByteString
"jpg"; forall (m :: * -> *) a. Monad m => a -> m a
return ImageType
JPG } -- ABS = Data.Attoparsec.ByteString
    png :: Parser ByteString ImageType
png = do { ByteString -> Parser ByteString
ABS.string ByteString
"png"; forall (m :: * -> *) a. Monad m => a -> m a
return ImageType
PNG }
    svg :: Parser ByteString ImageType
svg = do { ByteString -> Parser ByteString
ABS.string ByteString
"svg"; forall (m :: * -> *) a. Monad m => a -> m a
return ImageType
SVG }

    dataUri :: Parser ByteString (QDiagram b V2 n Any)
dataUri = do
      ByteString -> Parser ByteString
ABS.string ByteString
"data:image/"
      ImageType
imageType <- forall (f :: * -> *) a. Alternative f => [f a] -> f a
ABS.choice [Parser ByteString ImageType
jpg, Parser ByteString ImageType
png, Parser ByteString ImageType
svg]
      ByteString -> Parser ByteString
ABS.string ByteString
";base64," -- assuming currently that this is always used
      [Word8]
base64data <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
ABS.many1 Parser Word8
ABS.anyWord8
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case ImageType -> ByteString -> Either String DynamicImage
im ImageType
imageType ([Word8] -> ByteString
B.pack [Word8]
base64data) of
                 Right DynamicImage
img -> forall n a b.
(TypeableFloat n, Typeable a, Renderable (DImage n a) b) =>
DImage n a -> QDiagram b V2 n Any
image (forall b a.
ImageData b -> Int -> Int -> Transformation V2 a -> DImage a b
DImage (DynamicImage -> ImageData Embedded
ImageRaster DynamicImage
img) (forall a b. (RealFrac a, Integral b) => a -> b
round n
w) (forall a b. (RealFrac a, Integral b) => a -> b
round n
h) forall a. Monoid a => a
mempty)
                 Left String
x -> forall a. Monoid a => a
mempty

im :: ImageType -> B.ByteString -> Either String DynamicImage
im :: ImageType -> ByteString -> Either String DynamicImage
im ImageType
imageType ByteString
base64data = case ByteString -> Either String ByteString
Base64.decode ByteString
base64data of
   Left String
_ -> forall a b. a -> Either a b
Left String
"diagrams-input: Error decoding data uri in <image>-tag"
   Right ByteString
b64 -> case ImageType
imageType of
         ImageType
JPG -> ByteString -> Either String DynamicImage
decodeJpeg ByteString
b64 -- decodeJpeg :: ByteString -> Either String DynamicImage
         ImageType
PNG -> ByteString -> Either String DynamicImage
decodePng ByteString
b64
         --  SVG -> preserveAspectRatio w h oldWidth oldHeight ar (readSVGBytes base64data) -- something like that
         ImageType
_ -> forall a b. a -> Either a b
Left String
"diagrams-input: format not supported in <image>-tag"

-------------------------------------------------------------------------------------------------
-- | Parse \<text\>, see <http://www.w3.org/TR/SVG/text.html#TextElement>
parseText :: (MonadThrow m, InputConstraints b n, Read n, RealFloat n, Renderable (TT.Text n) b)
            => forall o. ConduitT Event o m (Maybe (Tag b n))
parseText :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, RealFloat n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseText = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}text" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
textAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen) ->
    do let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                      (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps) forall a. [a] -> [a] -> [a]
++
                      (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"text" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
       [Tag b n]
insideText <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many (forall {b} {m :: * -> *} {o}.
(V b ~ V2, MonadThrow m, RealFloat (N b), Typeable b,
 Typeable (N b), Show (N b), Read (N b),
 Renderable (Path V2 (N b)) b, Renderable (DImage (N b) Embedded) b,
 Renderable (Text (N b)) b) =>
(ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitT Event o m (Maybe (Tag b (N b)))
tContent (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen))
       forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
True (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca)
                             (Place
0, Place
0)
                             forall a. Maybe a
Nothing
                             forall a. Maybe a
Nothing
                             (\(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps -> forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps)
                             [Tag b n]
insideText

tContent :: (ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitT Event o m (Maybe (Tag b (N b)))
tContent (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen)
         = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose
           [ forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, RealFloat n, Read n,
 Renderable (Text n) b) =>
(ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitM Event o m (Maybe (Tag b n))
parseTSpan  (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen),
             forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, RealFloat n, Read n,
 Renderable (Text n) b) =>
(ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitM Event o m (Maybe (Tag b n))
textContent (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen) ]


{-
-- text related data of pa (presentation attribute)

alignmentBaseline baselineShift dominantBaseline fontFamily
fntSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight
glyphOrientationHorizontal glyphOrientationVertical kerning letterSpacing
textAnchor textDecoration textRendering wordSpacing writingMode
-}

-- | Parse a string between the text tags:  \<text\>Hello\</text\>
textContent :: (MonadThrow m, InputConstraints b n, RealFloat n, Read n, Renderable (TT.Text n) b) =>
               (ConditionalProcessingAttributes,
                CoreAttributes,
                GraphicalEventAttributes,
                PresentationAttributes,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text,
                Maybe Text) -> ConduitM Event o m (Maybe (Tag b n))
textContent :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, RealFloat n, Read n,
 Renderable (Text n) b) =>
(ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitM Event o m (Maybe (Tag b n))
textContent (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen) =
  do Maybe Text
t <- forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe Text)
contentMaybe
     let st :: (Read a, RealFloat a, RealFloat n) => (HashMaps b n, ViewBox n) -> [(SVGStyle n a)]
         st :: forall a n b.
(Read a, RealFloat a, RealFloat n) =>
(HashMaps b n, ViewBox n) -> [SVGStyle n a]
st (HashMaps b n
hmaps,ViewBox n
_) = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style HashMaps b n
hmaps) forall a. [a] -> [a] -> [a]
++
                        (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  HashMaps b n
hmaps)

     let f :: (V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n, Renderable (TT.Text n) b)
           => (HashMaps b n, ViewBox n) -> Diagram b
         f :: forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
(HashMaps b n, ViewBox n) -> Diagram b
f (HashMaps b n
maps,(n
minx,n
miny,n
w,n
h)) = forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
PresentationAttributes -> String -> QDiagram b V2 n Any
anchorText PresentationAttributes
pa (forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" Text -> String
T.unpack Maybe Text
t)
                                    -- fontWeight
                                    # scaleY (-1)
                                    # translate (r2 (p (minx,w) 0 x, p (miny,h) 0 y))
                                    # (applyTr (parseTr tr))
                                    # applyStyleSVG st (maps,(minx,miny,w,h))
                                    # maybe id (fontSize . local . read . T.unpack) (fntSize pa)
                                    # maybe id (font . T.unpack) (fontFamily pa)

     forall (m :: * -> *) a. Monad m => a -> m a
return (if forall a. Maybe a -> Bool
isJust Maybe Text
t then forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
(HashMaps b n, ViewBox n) -> Diagram b
f
                         else forall a. Maybe a
Nothing)


{-<tspan
         sodipodi:role="line"
         id="tspan2173"
         x="1551.4218"
         y="1056.9836" /> -}

-------------------------------------------------------------------------------------------------
-- | Parse \<tspan\>, see <https://www.w3.org/TR/SVG/text.html#TSpanElement>
parseTSpan :: (MonadThrow m, InputConstraints b n, RealFloat n, Read n, Renderable (TT.Text n) b) =>
              (ConditionalProcessingAttributes,
               CoreAttributes,
               GraphicalEventAttributes,
               PresentationAttributes,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text,
               Maybe Text) -> ConduitM Event o m (Maybe (Tag b n))
parseTSpan :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, RealFloat n, Read n,
 Renderable (Text n) b) =>
(ConditionalProcessingAttributes, CoreAttributes,
 GraphicalEventAttributes, PresentationAttributes, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
 Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
-> ConduitM Event o m (Maybe (Tag b n))
parseTSpan (ConditionalProcessingAttributes
cpa,CoreAttributes
ca,GraphicalEventAttributes
gea,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
tr,Maybe Text
la,Maybe Text
x,Maybe Text
y,Maybe Text
dx,Maybe Text
dy,Maybe Text
rot,Maybe Text
textlen) = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}tspan" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   GraphicalEventAttributes, PresentationAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
tspanAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa1,CoreAttributes
ca1,GraphicalEventAttributes
gea1,PresentationAttributes
pa1,Maybe Text
class1,Maybe Text
style1,Maybe Text
ext1,Maybe Text
x1,Maybe Text
y1,Maybe Text
dx1,Maybe Text
dy1,Maybe Text
rot1,Maybe Text
textlen1,Maybe Text
lAdjust1,Maybe Text
role) ->
    do Maybe Text
t <- forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe Text)
contentMaybe
       let st :: (Read a, RealFloat a, RealFloat n) => (HashMaps b n, ViewBox n) -> [(SVGStyle n a)]
           st :: forall a n b.
(Read a, RealFloat a, RealFloat n) =>
(HashMaps b n, ViewBox n) -> [SVGStyle n a]
st (HashMaps b n
hmaps,ViewBox n
_) = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style HashMaps b n
hmaps) forall a. [a] -> [a] -> [a]
++
                          (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style1 HashMaps b n
hmaps) forall a. [a] -> [a] -> [a]
++
                          (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa  HashMaps b n
hmaps) forall a. [a] -> [a] -> [a]
++
                          (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA  PresentationAttributes
pa1  HashMaps b n
hmaps) forall a. [a] -> [a] -> [a]
++
                          (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap HashMaps b n
hmaps Text
"tspan" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)

       let f :: (V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n, Renderable (TT.Text n) b)
             => (HashMaps b n, ViewBox n) -> Diagram b
           f :: forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
(HashMaps b n, ViewBox n) -> Diagram b
f (HashMaps b n
maps,(n
minx,n
miny,n
w,n
h)) = forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
PresentationAttributes -> String -> QDiagram b V2 n Any
anchorText PresentationAttributes
pa (forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" Text -> String
T.unpack Maybe Text
t)
                             # maybe id (fontSize . local . read . T.unpack) (pref (fntSize pa1) (fntSize pa))
                             # maybe id (font . T.unpack) (pref (fontFamily pa1) (fontFamily pa))
                             -- fontWeight
                             # scaleY (-1)
                             # translate (r2 (p (minx,w) 0 (pref x1 x), p (miny,h) 0 (pref y1 y)))
                             # (applyTr (parseTr tr))
                             # applyStyleSVG st (maps,(minx,miny,w,h))
       forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
(HashMaps b n, ViewBox n) -> Diagram b
f


anchorText :: (V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n, Renderable (TT.Text n) b)
           => PresentationAttributes -> String -> QDiagram b V2 n Any
anchorText :: forall b n.
(V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable n,
 Renderable (Text n) b) =>
PresentationAttributes -> String -> QDiagram b V2 n Any
anchorText PresentationAttributes
pa String
txt = case PresentationAttributes -> String
anchor PresentationAttributes
pa of 
    String
"start"   -> forall n b.
(TypeableFloat n, Renderable (Text n) b) =>
String -> QDiagram b V2 n Any
baselineText String
txt
    String
"middle"  -> forall n b.
(TypeableFloat n, Renderable (Text n) b) =>
String -> QDiagram b V2 n Any
text String
txt
    String
"end"     -> forall n b.
(TypeableFloat n, Renderable (Text n) b) =>
n -> n -> String -> QDiagram b V2 n Any
alignedText n
1 n
0 String
txt -- TODO is this correct?
    String
"inherit" -> forall n b.
(TypeableFloat n, Renderable (Text n) b) =>
String -> QDiagram b V2 n Any
text String
txt -- TODO
  where
    anchor :: PresentationAttributes -> String
anchor PresentationAttributes
pa = forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"start" Text -> String
T.unpack (PresentationAttributes -> Maybe Text
textAnchor PresentationAttributes
pa) -- see <https://www.w3.org/TR/SVG/text.html#TextAnchorProperty>


pref :: Maybe a -> Maybe a -> Maybe a
pref :: forall a. Maybe a -> Maybe a -> Maybe a
pref (Just a
x) Maybe a
b       = forall a. a -> Maybe a
Just a
x
pref Maybe a
Nothing (Just a
y) = forall a. a -> Maybe a
Just a
y
pref Maybe a
Nothing Maybe a
Nothing  = forall a. Maybe a
Nothing


--------------------------------------------------------------------------------------
-- Gradients
-------------------------------------------------------------------------------------

-- | Parse \<linearGradient\>, see <http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement>
-- example: <linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="68.2461" y1="197.6797"
--           x2="52.6936" y2="237.5337" gradientTransform="matrix(1 0 0 -1 -22.5352 286.4424)">
parseLinearGradient :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseLinearGradient :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseLinearGradient = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}linearGradient" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
linearGradAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
x1,Maybe Text
y1,Maybe Text
x2,Maybe Text
y2,Maybe Text
gradientUnits,Maybe Text
gradientTransform,Maybe Text
spreadMethod) -> -- TODO gradientUnits
  do [Tag Any n]
gs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall {m :: * -> *} {n} {o} {b}.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
gradientContent
     let stops :: [HashMap Text Attrs -> [GradientStop n]]
stops = forall a b. (a -> b) -> [a] -> [b]
map forall n b.
RealFloat n =>
Tag b n -> HashMap Text Attrs -> [GradientStop n]
getTexture forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall {b} {n}. Tag b n -> [Tag b n]
extractStops [Tag Any n]
gs

     -- because of href we have to replace Nothing-attributes by attributes of referenced gradients
     -- see <http://www.w3.org/TR/SVG/pservers.html#RadialGradientElementHrefAttribute>
     let attributes :: GradientAttributes
attributes = PresentationAttributes
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GradientAttributes
GA PresentationAttributes
pa Maybe Text
class_ Maybe Text
style Maybe Text
x1 Maybe Text
y1 Maybe Text
x2 Maybe Text
y2 forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing Maybe Text
gradientUnits Maybe Text
gradientTransform Maybe Text
spreadMethod

     -- stops are lists of functions and everyone of these gets passed the same cssmap
     -- and puts them into a Grad constructor
     let f :: HashMap Text Attrs
-> GradientAttributes
-> (n, n, n, n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> Texture n
f HashMap Text Attrs
css GradientAttributes
attributes (n
minx,n
miny,n
w,n
h) [HashMap Text Attrs -> [GradientStop n]]
stops =
           forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (forall n. Prism' (Texture n) (LGradient n)
_LG forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. Lens' (LGradient n) (Transformation V2 n)
lGradTrans) (forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
gradientTransform))
           (forall n.
Num n =>
[GradientStop n]
-> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n
mkLinearGradient (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (a -> b) -> a -> b
$ HashMap Text Attrs
css) [HashMap Text Attrs -> [GradientStop n]]
stops)) -- (minx,miny,w,h) is the viewbox
                             ((forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
x1) forall c. Coordinates c => PrevDim c -> FinalCoord c -> c
^& (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
y1))
                             ((forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
x2) forall c. Coordinates c => PrevDim c -> FinalCoord c -> c
^& (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
y2))
                             (Maybe Text -> SpreadMethod
parseSpread Maybe Text
spreadMethod))
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Maybe Text -> Gr n -> Tag b n
Grad (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (forall n.
Maybe Text
-> GradientAttributes
-> Maybe (ViewBox n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> (HashMap Text Attrs
    -> GradientAttributes
    -> ViewBox n
    -> [HashMap Text Attrs -> [GradientStop n]]
    -> Texture n)
-> Gr n
Gr (Maybe Text -> Maybe Text
Diagrams.SVG.Attributes.fragment forall a b. (a -> b) -> a -> b
$ XlinkAttributes -> Maybe Text
xlinkHref XlinkAttributes
xlink) GradientAttributes
attributes forall a. Maybe a
Nothing [HashMap Text Attrs -> [GradientStop n]]
stops HashMap Text Attrs
-> GradientAttributes
-> (n, n, n, n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> Texture n
f)

gradientContent :: ConduitT Event o m (Maybe (Tag b n))
gradientContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [forall {m :: * -> *} {n} {o} {b}.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseStop, forall {m :: * -> *} {n} {o} {b}.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseMidPointStop] -- parseSet,
   --   parseDesc, parseMetaData, parseTitle] -- descriptive Elements (rarely used here, so tested at the end)

-- | Parse \<radialGradient\>, see <http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement>
parseRadialGradient :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseRadialGradient :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
parseRadialGradient = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}radialGradient" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
radialGradAttrs forall a b. (a -> b) -> a -> b
$ -- TODO gradientUnits
  \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
cx,Maybe Text
cy,Maybe Text
r,Maybe Text
fx,Maybe Text
fy,Maybe Text
gradientUnits,Maybe Text
gradientTransform,Maybe Text
spreadMethod) -> 
  do [Tag Any n]
gs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall {m :: * -> *} {n} {o} {b}.
(MonadThrow m, RealFloat n) =>
ConduitT Event o m (Maybe (Tag b n))
gradientContent
     let stops :: [HashMap Text Attrs -> [GradientStop n]]
stops = forall a b. (a -> b) -> [a] -> [b]
map forall n b.
RealFloat n =>
Tag b n -> HashMap Text Attrs -> [GradientStop n]
getTexture forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall {b} {n}. Tag b n -> [Tag b n]
extractStops [Tag Any n]
gs

     -- because of href we have to replace Nothing-attributes by attributes of referenced gradients
     -- see <http://www.w3.org/TR/SVG/pservers.html#RadialGradientElementHrefAttribute>
     let attributes :: GradientAttributes
attributes = PresentationAttributes
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GradientAttributes
GA PresentationAttributes
pa Maybe Text
class_ Maybe Text
style forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing Maybe Text
cx Maybe Text
cy Maybe Text
r Maybe Text
fx Maybe Text
fy Maybe Text
gradientUnits Maybe Text
gradientTransform Maybe Text
spreadMethod

     let f :: HashMap Text Attrs
-> GradientAttributes
-> (n, n, n, n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> Texture n
f HashMap Text Attrs
css GradientAttributes
attributes (n
minx,n
miny,n
w,n
h) [HashMap Text Attrs -> [GradientStop n]]
stops =
            forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (forall n. Prism' (Texture n) (RGradient n)
_RG forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n. Lens' (RGradient n) (Transformation V2 n)
rGradTrans) (forall {a}.
(V a ~ V2, Transformable a, RealFloat (N a), Additive (V a),
 R2 (V a)) =>
[Transform (N a)] -> a -> a
applyTr (forall n. RealFloat n => Maybe Text -> [Transform n]
parseTr Maybe Text
gradientTransform))
            (forall n.
Num n =>
[GradientStop n]
-> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n
mkRadialGradient (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (a -> b) -> a -> b
$ HashMap Text Attrs
css) [HashMap Text Attrs -> [GradientStop n]]
stops))
                              ((forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0 Maybe Text
cx) Maybe Text
fx) forall c. Coordinates c => PrevDim c -> FinalCoord c -> c
^& -- focal point fx is set to cx if fx does not exist
                              (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0 Maybe Text
cy) Maybe Text
fy))
                              n
0
                              ((forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) n
0             Maybe Text
cx) forall c. Coordinates c => PrevDim c -> FinalCoord c -> c
^& 
                              (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
miny,n
h) n
0             Maybe Text
cy))
                              (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
minx,n
w) (n
0.5forall a. Num a => a -> a -> a
*(n
wforall a. Num a => a -> a -> a
-n
minx)) Maybe Text
r) --TODO radius percentage relative to x or y?
                              (Maybe Text -> SpreadMethod
parseSpread Maybe Text
spreadMethod))
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Maybe Text -> Gr n -> Tag b n
Grad (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (forall n.
Maybe Text
-> GradientAttributes
-> Maybe (ViewBox n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> (HashMap Text Attrs
    -> GradientAttributes
    -> ViewBox n
    -> [HashMap Text Attrs -> [GradientStop n]]
    -> Texture n)
-> Gr n
Gr (Maybe Text -> Maybe Text
Diagrams.SVG.Attributes.fragment forall a b. (a -> b) -> a -> b
$ XlinkAttributes -> Maybe Text
xlinkHref XlinkAttributes
xlink) GradientAttributes
attributes forall a. Maybe a
Nothing [HashMap Text Attrs -> [GradientStop n]]
stops HashMap Text Attrs
-> GradientAttributes
-> (n, n, n, n)
-> [HashMap Text Attrs -> [GradientStop n]]
-> Texture n
f)

extractStops :: Tag b n -> [Tag b n]
extractStops (SubTree Bool
b Maybe Text
id1 (Place, Place)
wh Maybe (ViewBox n)
viewBox Maybe PreserveAR
ar HashMaps b n -> Diagram b -> Diagram b
f [Tag b n]
children) = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a b. (a -> b) -> [a] -> [b]
map Tag b n -> [Tag b n]
extractStops [Tag b n]
children)
extractStops (Stop HashMaps b n -> [GradientStop n]
stops) = [forall b n. (HashMaps b n -> [GradientStop n]) -> Tag b n
Stop HashMaps b n -> [GradientStop n]
stops]
extractStops Tag b n
_ = []

getTexture :: (RealFloat n) => Tag b n -> (CSSMap -> [GradientStop n])
getTexture :: forall n b.
RealFloat n =>
Tag b n -> HashMap Text Attrs -> [GradientStop n]
getTexture (Stop HashMaps b n -> [GradientStop n]
stops) = HashMaps b n -> [GradientStop n]
stops forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\HashMap Text Attrs
css -> (forall k v. HashMap k v
H.empty, HashMap Text Attrs
css, forall k v. HashMap k v
H.empty))

-- | Parse \<set\>, see <http://www.w3.org/TR/SVG/animate.html#SetElement>
parseSet :: ConduitT Event o m (Maybe (Tag b n))
parseSet = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}set" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes)
setAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink) ->
   do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty -- "set" ignored so far

-- | Parse \<stop\>, see <http://www.w3.org/TR/SVG/pservers.html#StopElement>
--  e.g. <stop  offset="0.4664" style="stop-color:#000000;stop-opacity:0.8"/>
parseStop :: ConduitT Event o m (Maybe (Tag b n))
parseStop = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}stop" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text)
stopAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
offset) ->
   do let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style forall {k} {v} {k} {v} {k} {v}.
(HashMap k v, HashMap k v, HashMap k v)
empty3) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA PresentationAttributes
pa forall {k} {v} {k} {v} {k} {v}.
(HashMap k v, HashMap k v, HashMap k v)
empty3) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"stop" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. (HashMaps b n -> [GradientStop n]) -> Tag b n
Stop (\(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps -> forall d. [(Colour Place, d, Place)] -> [GradientStop d]
mkStops [forall {b} {n}. b -> [SVGStyle n Place] -> (Colour Place, b, Place)
getStopTriple (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
0,n
1) n
0 Maybe Text
offset) ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps)])

parseMidPointStop :: ConduitT Event o m (Maybe (Tag b n))
parseMidPointStop = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}midPointStop" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text)
stopAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
offset) ->
   do let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style forall {k} {v} {k} {v} {k} {v}.
(HashMap k v, HashMap k v, HashMap k v)
empty3) forall a. [a] -> [a] -> [a]
++
                     (forall n a b.
(RealFloat n, RealFloat a, Read a) =>
PresentationAttributes -> HashMaps b n -> [SVGStyle n a]
parsePA PresentationAttributes
pa forall {k} {v} {k} {v} {k} {v}.
(HashMap k v, HashMap k v, HashMap k v)
empty3) forall a. [a] -> [a] -> [a]
++
                     (forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> Text -> Maybe Text -> Maybe Text -> [SVGStyle n a]
cssStylesFromMap (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps Text
"midPointStop" (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
class_)
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. (HashMaps b n -> [GradientStop n]) -> Tag b n
Stop (\(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps -> forall d. [(Colour Place, d, Place)] -> [GradientStop d]
mkStops [forall {b} {n}. b -> [SVGStyle n Place] -> (Colour Place, b, Place)
getStopTriple (forall n. RealFloat n => (n, n) -> n -> Maybe Text -> n
p (n
0,n
1) n
0 Maybe Text
offset) ((HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps)])

empty3 :: (HashMap k v, HashMap k v, HashMap k v)
empty3 = (forall k v. HashMap k v
H.empty,forall k v. HashMap k v
H.empty,forall k v. HashMap k v
H.empty)

getStopTriple :: b -> [SVGStyle n Place] -> (Colour Place, b, Place)
getStopTriple b
offset [SVGStyle n Place]
styles = (forall {n}. [SVGStyle n Place] -> Colour Place
col [SVGStyle n Place]
colors, b
offset, forall {n} {a}. [SVGStyle n a] -> Place
opacity [SVGStyle n Place]
opacities)
  where col :: [SVGStyle n Place] -> Colour Place
col ((Fill AlphaColour Place
c):[SVGStyle n Place]
_) = forall c. Color c => AlphaColour Place -> c
fromAlphaColour AlphaColour Place
c
        col [SVGStyle n Place]
_ = forall a. (Ord a, Floating a) => Colour a
white
        opacity :: [SVGStyle n a] -> Place
opacity ((FillOpacity Place
x):[SVGStyle n a]
_) = Place
x
        opacity [SVGStyle n a]
_ =  Place
1
        colors :: [SVGStyle n Place]
colors = forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {n} {a}. SVGStyle n a -> Bool
isFill [SVGStyle n Place]
styles
        opacities :: [SVGStyle n Place]
opacities = forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {n} {a}. SVGStyle n a -> Bool
isOpacity [SVGStyle n Place]
styles

isFill :: SVGStyle n a -> Bool
isFill (Fill AlphaColour a
_) = Bool
True
isFill SVGStyle n a
_        = Bool
False

isOpacity :: SVGStyle n a -> Bool
isOpacity (FillOpacity Place
_) = Bool
True
isOpacity SVGStyle n a
_           = Bool
False

----------------------------------------------------------------------------------------------------
-- Fonts
----------------------------------------------------------------------------------------------------

parseFont :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Renderable (DImage (N b) Embedded) b, Renderable (Path V2 n) b,
              Typeable b, Typeable n, Show n, Read n, Renderable (TT.Text n) b) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseFont :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Renderable (Path V2 n) b,
 Typeable b, Typeable n, Show n, Read n, Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
parseFont = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}font" AttrParser
  (CoreAttributes, PresentationAttributes, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
fontAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
hOriginX,Maybe Text
hOriginY,Maybe Text
hAdvX,Maybe Text
vOriginX,Maybe Text
vOriginY,Maybe Text
vAdvY) ->
  do [FontContent b n]
gs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, Show n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (FontContent b n))
fontContent
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. FontData b n -> Tag b n
FontTag forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> Maybe Text
-> Maybe Text
-> n
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> FontFace n
-> Glyph b n
-> SvgGlyphs n
-> KernMaps n
-> FontData b n
FontData (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Maybe Text
hOriginX Maybe Text
hOriginY (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
hAdvX) Maybe Text
vOriginX Maybe Text
vOriginY Maybe Text
vAdvY 
                                 (forall {b} {n}. [FontContent b n] -> FontFace n
fontf [FontContent b n]
gs) (forall {b} {n}. [FontContent b n] -> Glyph b n
missingGlyph [FontContent b n]
gs) (forall {b} {b}.
[FontContent b b] -> HashMap Text (Maybe Text, b, Maybe Text)
glyphs [FontContent b n]
gs) (forall n. [Kern n] -> KernMaps n
kernMap (forall {b} {n}. [FontContent b n] -> [Kern n]
kerns [FontContent b n]
gs))
  where fontf :: [FontContent b n] -> FontFace n
fontf [FontContent b n]
gs        = (\(FF FontFace n
f) -> FontFace n
f) forall a b. (a -> b) -> a -> b
$ forall a. [a] -> a
head forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {b} {n}. FontContent b n -> Bool
isFontFace [FontContent b n]
gs
        missingGlyph :: [FontContent b n] -> Glyph b n
missingGlyph [FontContent b n]
gs = (\(GG Glyph b n
g) -> Glyph b n
g) forall a b. (a -> b) -> a -> b
$ forall a. [a] -> a
head forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {b} {n}. FontContent b n -> Bool
isMissingGlyph [FontContent b n]
gs
        glyphs :: [FontContent b b] -> HashMap Text (Maybe Text, b, Maybe Text)
glyphs [FontContent b b]
gs       = forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
H.fromList forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall {b} {b}.
FontContent b b -> (Text, (Maybe Text, b, Maybe Text))
toSvgGlyph     (forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {b} {n}. FontContent b n -> Bool
isGlyph [FontContent b b]
gs)
        kerns :: [FontContent b n] -> [Kern n]
kerns [FontContent b n]
gs = forall a b. (a -> b) -> [a] -> [b]
map (\(KK Kern n
k) -> Kern n
k) (forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter forall {b} {n}. FontContent b n -> Bool
isKern [FontContent b n]
gs)

        isGlyph :: FontContent b n -> Bool
isGlyph (GG (Glyph Maybe Text
glyphId Tag b n
g Maybe Text
d n
_ n
_ n
_ n
_ Maybe Text
unicode Maybe Text
glyphName Maybe Text
o Maybe Text
a Maybe Text
l)) = Bool -> Bool
not (forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Text -> Bool
T.null Maybe Text
unicode) Bool -> Bool -> Bool
||
                                                                           Bool -> Bool
not (forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Text -> Bool
T.null Maybe Text
glyphName)
        isGlyph FontContent b n
_        = Bool
False
        isMissingGlyph :: FontContent b n -> Bool
isMissingGlyph (GG (Glyph Maybe Text
glyphId Tag b n
g Maybe Text
d n
_ n
_ n
_ n
_ Maybe Text
unicode Maybe Text
glyphName Maybe Text
o Maybe Text
a Maybe Text
l)) = (forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Text -> Bool
T.null Maybe Text
unicode) Bool -> Bool -> Bool
&&
                                                                                  (forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Text -> Bool
T.null Maybe Text
glyphName)
        isMissingGlyph FontContent b n
_  = Bool
False
        isKern :: FontContent b n -> Bool
isKern (KK Kern n
k)     = Bool
True
        isKern FontContent b n
_          = Bool
False
        isFontFace :: FontContent b n -> Bool
isFontFace (FF FontFace n
f) = Bool
True
        isFontFace FontContent b n
_      = Bool
False
        toSvgGlyph :: FontContent b b -> (Text, (Maybe Text, b, Maybe Text))
toSvgGlyph (GG (Glyph Maybe Text
glyphId Tag b b
g Maybe Text
d b
horizAdvX b
_ b
_ b
_ (Just Text
unicode) Maybe Text
glyphName Maybe Text
o Maybe Text
a Maybe Text
l)) = (Text
unicode,(Maybe Text
glyphName,b
horizAdvX,Maybe Text
d))

fontContent :: (MonadThrow m, InputConstraints b n, Read n, Show n, Renderable (TT.Text n) b) 
             => forall o. ConduitT Event o m (Maybe (FontContent b n))
fontContent :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Read n, Show n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (FontContent b n))
fontContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose -- the likely most common are checked first
     [forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n,
 Renderable (DImage (N b) Embedded) b, Renderable (Path V2 n) b,
 Show n, Typeable b, Typeable n, Renderable (Text n) b) =>
ConduitT Event o m (Maybe (FontContent b n))
parseGlyph, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b,
 Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseHKern, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, Read n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseFontFace, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseMissingGlyph, forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b,
 Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseVKern]


parseFontFace :: (MonadThrow m, V b ~ V2, N b ~ n, Read n, RealFloat n, Renderable (DImage (N b) Embedded) b,
              Typeable b, Typeable n) => forall o. ConduitT Event o m (Maybe (FontContent b n))
parseFontFace :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, Read n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseFontFace = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}font-face" AttrParser
  (CoreAttributes, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
fontFaceAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,Maybe Text
fontFamily,Maybe Text
fontStyle,Maybe Text
fontVariant,Maybe Text
fontWeight,Maybe Text
fontStretch,Maybe Text
fontSize,Maybe Text
unicodeRange,Maybe Text
unitsPerEm,Maybe Text
panose1,
    Maybe Text
stemv,Maybe Text
stemh,Maybe Text
slope,Maybe Text
capHeight,Maybe Text
xHeight,Maybe Text
accentHeight,Maybe Text
ascent,Maybe Text
descent,Maybe Text
widths,Maybe Text
bbox,Maybe Text
ideographic,Maybe Text
alphabetic,Maybe Text
mathematical,
    Maybe Text
hanging,Maybe Text
vIdeographic,Maybe Text
vAlphabetic,Maybe Text
vMathematical,Maybe Text
vHanging,Maybe Text
underlinePosition,Maybe Text
underlineThickness,Maybe Text
strikethroughPosition,
    Maybe Text
strikethroughThickness,Maybe Text
overlinePosition,Maybe Text
overlineThickness) ->
  do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. FontFace n -> FontContent b n
FF forall a b. (a -> b) -> a -> b
$ forall n.
Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> [n]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> FontFace n
FontFace Maybe Text
fontFamily Maybe Text
fontStyle Maybe Text
fontVariant Maybe Text
fontWeight Maybe Text
fontStretch Maybe Text
fontSize Maybe Text
unicodeRange Maybe Text
unitsPerEm Maybe Text
panose1
                            Maybe Text
stemv Maybe Text
stemh Maybe Text
slope Maybe Text
capHeight Maybe Text
xHeight Maybe Text
accentHeight Maybe Text
ascent Maybe Text
descent Maybe Text
widths (forall n. (Read n, RealFloat n) => Maybe Text -> [n]
parseBBox Maybe Text
bbox) Maybe Text
ideographic
                            Maybe Text
alphabetic Maybe Text
mathematical Maybe Text
hanging Maybe Text
vIdeographic Maybe Text
vAlphabetic  Maybe Text
vMathematical Maybe Text
vHanging Maybe Text
underlinePosition 
                            Maybe Text
underlineThickness Maybe Text
strikethroughPosition Maybe Text
strikethroughThickness Maybe Text
overlinePosition Maybe Text
overlineThickness


parseMissingGlyph :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Renderable (DImage (N b) Embedded) b,
              Typeable b, Typeable n) => forall o. ConduitT Event o m (Maybe (FontContent b n))
parseMissingGlyph :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseMissingGlyph = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}missing-glyph" AttrParser
  (CoreAttributes, PresentationAttributes, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
missingGlyphAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
d,Maybe Text
horizAdvX,Maybe Text
vertOriginX,Maybe Text
vertOriginY,Maybe Text
vertAdvY) ->
  do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Glyph b n -> FontContent b n
GG forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> Tag b n
-> Maybe Text
-> n
-> n
-> n
-> n
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Glyph b n
Glyph (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty) forall a. Maybe a
Nothing
                         (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
horizAdvX) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertOriginX) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertOriginY) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertAdvY)
                         forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing


parseGlyph :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Renderable (DImage (N b) Embedded) b,
              Renderable (Path V2 n) b, Show n, Typeable b, Typeable n, Renderable (TT.Text n) b) 
           => forall o. ConduitT Event o m (Maybe (FontContent b n))
parseGlyph :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n,
 Renderable (DImage (N b) Embedded) b, Renderable (Path V2 n) b,
 Show n, Typeable b, Typeable n, Renderable (Text n) b) =>
ConduitT Event o m (Maybe (FontContent b n))
parseGlyph = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}glyph" AttrParser
  (CoreAttributes, PresentationAttributes, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
glyphAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
d,Maybe Text
horizAdvX,Maybe Text
vertOriginX,Maybe Text
vertOriginY,Maybe Text
vertAdvY,Maybe Text
unicode,Maybe Text
glyphName,Maybe Text
orientation,Maybe Text
arabicForm,Maybe Text
lang) ->
  do [Tag b n]
gs <- forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Show n, Read n,
 Renderable (Text n) b) =>
ConduitT Event o m (Maybe (Tag b n))
gContent
     let st :: (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps = forall {n} {a} {b}.
(RealFloat n, RealFrac a, Floating a) =>
Maybe Text
-> (HashMap Text (Tag b n), HashMap Text Attrs,
    HashMap Text (Gr n))
-> [SVGStyle n a]
parseStyles Maybe Text
style (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
hmaps
     let sub :: Tag b n
sub = forall b n.
Bool
-> Maybe Text
-> (Place, Place)
-> Maybe (ViewBox n)
-> Maybe PreserveAR
-> (HashMaps b n -> Diagram b -> Diagram b)
-> [Tag b n]
-> Tag b n
SubTree Bool
True (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) (Place
0,Place
0) forall a. Maybe a
Nothing forall a. Maybe a
Nothing (\(HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps -> (forall {a} {t}.
(V a ~ V2, HasStyle a, Typeable (N a), RealFloat (N a)) =>
(t -> [SVGStyle (N a) Place]) -> t -> a -> a
applyStyleSVG (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
-> [SVGStyle n Place]
st (HashMap Text (Tag b n), HashMap Text Attrs, HashMap Text (Gr n))
maps)) (forall a. [a] -> [a]
reverse [Tag b n]
gs)
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Glyph b n -> FontContent b n
GG forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> Tag b n
-> Maybe Text
-> n
-> n
-> n
-> n
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Glyph b n
Glyph (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) Tag b n
sub Maybe Text
d (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
horizAdvX) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertOriginX) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertOriginY) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
vertAdvY)
                         Maybe Text
unicode Maybe Text
glyphName Maybe Text
orientation Maybe Text
arabicForm Maybe Text
lang

getN :: Maybe Text -> b
getN = forall b a. b -> (a -> b) -> Maybe a -> b
maybe b
0 (forall a. Read a => String -> a
read forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack)

parseHKern :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b, Typeable n) => forall o. ConduitT Event o m (Maybe (FontContent b n))
parseHKern :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b,
 Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseHKern = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}hkern" AttrParser
  (CoreAttributes, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
kernAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,Maybe Text
u1,Maybe Text
g1,Maybe Text
u2,Maybe Text
g2,Maybe Text
k) ->
  do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Kern n -> FontContent b n
KK forall a b. (a -> b) -> a -> b
$ forall n.
KernDir -> [Text] -> [Text] -> [Text] -> [Text] -> n -> Kern n
Kern KernDir
HKern (Maybe Text -> [Text]
charList Maybe Text
u1) (Maybe Text -> [Text]
charList Maybe Text
g1) (Maybe Text -> [Text]
charList Maybe Text
u2) (Maybe Text -> [Text]
charList Maybe Text
g2) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
k)

parseVKern :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b, Typeable n) => forall o. ConduitT Event o m (Maybe (FontContent b n))
parseVKern :: forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n, Read n, Typeable b,
 Typeable n) =>
ConduitT Event o m (Maybe (FontContent b n))
parseVKern = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}vkern" AttrParser
  (CoreAttributes, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
kernAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,Maybe Text
u1,Maybe Text
g1,Maybe Text
u2,Maybe Text
g2,Maybe Text
k) ->
  do forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n. Kern n -> FontContent b n
KK forall a b. (a -> b) -> a -> b
$ forall n.
KernDir -> [Text] -> [Text] -> [Text] -> [Text] -> n -> Kern n
Kern KernDir
VKern (Maybe Text -> [Text]
charList Maybe Text
u1) (Maybe Text -> [Text]
charList Maybe Text
g1) (Maybe Text -> [Text]
charList Maybe Text
u2) (Maybe Text -> [Text]
charList Maybe Text
g2) (forall {b}. (Num b, Read b) => Maybe Text -> b
getN Maybe Text
k)

charList :: Maybe Text -> [Text]
charList :: Maybe Text -> [Text]
charList Maybe Text
str = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (Text -> Text -> [Text]
T.splitOn Text
",") Maybe Text
str

----------------------------------------------------------------------------------------
-- descriptive elements
------------------------------------------------------o	----------------------------------
-- | Parse \<desc\>, see <http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements>
-- parseDesc :: (MonadThrow m, Metric (V b), RealFloat (N b)) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseDesc :: ConduitT Event o m (Maybe (Tag b n))
parseDesc = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}desc" AttrParser (CoreAttributes, Maybe Text, Maybe Text)
descAttrs
   forall a b. (a -> b) -> a -> b
$ \(CoreAttributes
ca,Maybe Text
class_,Maybe Text
style) ->
   do Text
desc <- forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<title\>, see <http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements>
parseTitle :: ConduitT Event o m (Maybe (Tag b n))
parseTitle = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}title" AttrParser (CoreAttributes, Maybe Text, Maybe Text)
descAttrs
   forall a b. (a -> b) -> a -> b
$ \(CoreAttributes
ca,Maybe Text
class_,Maybe Text
style) ->
   do Text
title <- forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

skipArbitraryTag :: (MonadThrow m, InputConstraints b n, Renderable (TT.Text n) b, Read n) => forall o. ConduitT Event o m (Maybe (Tag b n))
skipArbitraryTag :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n, Renderable (Text n) b,
 Read n) =>
ConduitT Event o m (Maybe (Tag b n))
skipArbitraryTag = do Maybe ()
t <- forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe ())
ignoreAnyTreeContent
                      if forall a. Maybe a -> Bool
isJust Maybe ()
t then forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (forall a. a -> Maybe a
Just Text
"") forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty)
                                  else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing

-- | Parse \<meta\>, see <http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements>
--
-- @
-- An example what metadata contains:
--
--  \<metadata
--     id=\"metadata22\"\>
--    \<rdf:RDF\>
--      \<cc:Work
--         rdf:about=\"\"\>
--        \<dc:format\>image\/svg+xml\<\/dc:format\>
--        \<dc:type
--           rdf:resource=\"http:\/\/purl.org\/dc\/dcmitype\/StillImage\" \/\>
--      \</cc:Work\>
--    \</rdf:RDF\>
--  \</metadata\>
-- @
--
{-  Maybe we implement it one day

parseMetaData :: (MonadThrow m, V b ~ V2, N b ~ n, RealFloat n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseMetaData = tagName "{http://www.w3.org/2000/svg}metadata" ignoreAttrs
   $ \_ ->
   do -- meta <- many metaContent
      return $ Leaf Nothing mempty mempty

-- metaContent :: (MonadThrow m, Metric (V b), RealFloat (N b)) => forall o. ConduitT Event o m (Maybe (Tag b n))
metaContent = choose [parseRDF] -- extend if needed

-- parseRDF :: (MonadThrow m, Metric (V b), RealFloat (N b)) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseRDF = tagName "{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF" ignoreAttrs
          $ \_ ->
          do -- c <- parseWork
             return $ Leaf Nothing mempty mempty

-- parseWork :: (MonadThrow m, Metric (V b), RealFloat (N b)) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseWork = tagName "{http://creativecommons.org/ns#}Work" ignoreAttrs
   $ \_ ->
   do -- c <- many workContent
      return $ Leaf Nothing mempty mempty

workContent = choose [parseFormat, parseType, parseRDFTitle, parseDate, parseCreator,
                      parsePublisher, parseSource, parseLanguage, parseSubject, parseDescription]

parseCreator = tagName "{http://purl.org/dc/elements/1.1/}creator" ignoreAttrs
   $ \_ -> do { c <- parseAgent ; return $ Leaf Nothing mempty mempty }

parseAgent = tagName "{http://creativecommons.org/ns#}Agent" ignoreAttrs
   $ \_ -> do { c <- parseAgentTitle ; return $ Leaf Nothing mempty mempty }

parsePublisher = tagName "{http://purl.org/dc/elements/1.1/}publisher" ignoreAttrs
   $ \_ -> do { c <- parseAgent ; return $ Leaf Nothing mempty mempty }

parseSubject = tagName "{http://purl.org/dc/elements/1.1/}subject" ignoreAttrs
   $ \_ -> do { c <- parseBag ; return $ Leaf Nothing mempty mempty }

-- parseBag :: (MonadThrow m, Metric (V b), Ord (N b), Floating (N b)) => forall o. ConduitT Event o m (Maybe (Tag b n))
parseBag = tagName "{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Bag" ignoreAttrs
   $ \_ -> do { c <- parseList ; return $ Leaf Nothing mempty mempty }

parseFormat = tagName "{http://purl.org/dc/elements/1.1/}format" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseType = tagName "{http://purl.org/dc/elements/1.1/}type" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseRDFTitle = tagName "{http://purl.org/dc/elements/1.1/}title" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseDate = tagName "{http://purl.org/dc/elements/1.1/}date" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseAgentTitle = tagName "{http://purl.org/dc/elements/1.1/}title" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseSource = tagName "{http://purl.org/dc/elements/1.1/}source" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseLanguage = tagName "{http://purl.org/dc/elements/1.1/}language" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseList = tagName "{http://www.w3.org/1999/02/22-rdf-syntax-ns#}li" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }

parseDescription = tagName "{http://purl.org/dc/elements/1.1/}description" ignoreAttrs
   $ \_ -> do { c <- content ; return $ Leaf Nothing mempty mempty }
-}
------------------------------------
-- inkscape / sodipodi tags
------------------------------------
parseSodipodi :: ConduitT Event o m (Maybe (Tag b n))
parseSodipodi = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}namedview" AttrParser
  (Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
namedViewAttrs
   forall a b. (a -> b) -> a -> b
$ \(Maybe Text
pc,Maybe Text
bc,Maybe Text
bo,Maybe Text
ot,Maybe Text
gt,Maybe Text
gut,Maybe Text
po,Maybe Text
ps,Maybe Text
ww,Maybe Text
wh,Maybe Text
id1,Maybe Text
sg,Maybe Text
zoom,Maybe Text
cx,Maybe Text
cy,Maybe Text
wx,Maybe Text
wy,Maybe Text
wm,Maybe Text
cl) ->
   do -- c <- parseGrid
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (forall a. a -> Maybe a
Just Text
"") forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

--    <inkscape:grid
--       type="xygrid"
--       id="grid5177" />
parseGrid :: ConduitT Event o m (Maybe (Tag b n))
parseGrid = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.inkscape.org/namespaces/inkscape}grid" AttrParser ()
ignoreAttrs
   forall a b. (a -> b) -> a -> b
$ \()
_ ->
   do Text
c <- forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
      forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf forall a. Maybe a
Nothing forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

{-   <inkscape:perspective
       sodipodi:type="inkscape:persp3d"
       inkscape:vp_x="0 : 212.5 : 1"
       inkscape:vp_y="0 : 1000 : 0"
       inkscape:vp_z="428.75 : 212.5 : 1"
       inkscape:persp3d-origin="214.375 : 141.66667 : 1"
       id="perspective5175" />
-}

parsePerspective :: ConduitT Event o m (Maybe (Tag b n))
parsePerspective = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.inkscape.org/namespaces/inkscape}perspective" AttrParser
  (Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
perspectiveAttrs
   forall a b. (a -> b) -> a -> b
$ \(Maybe Text
typ,Maybe Text
vp_x,Maybe Text
vp_y,Maybe Text
vp_z,Maybe Text
persp3d_origin,Maybe Text
id_) ->
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (forall a. a -> Maybe a
Just Text
"") forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

parsePathEffect :: ConduitT Event o m (Maybe (Tag b n))
parsePathEffect = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.inkscape.org/namespaces/inkscape}path-effect" AttrParser ()
ignoreAttrs
   forall a b. (a -> b) -> a -> b
$ \()
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf forall a. Maybe a
Nothing forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
--------------------------------------------------------------------------------------
-- sceletons

-- | Parse \<pattern\>, see <http://www.w3.org/TR/SVG/pservers.html#PatternElement>
parsePattern :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
parsePattern :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
parsePattern = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}pattern" AttrParser
  (ConditionalProcessingAttributes, CoreAttributes,
   PresentationAttributes, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
patternAttrs forall a b. (a -> b) -> a -> b
$
  \(ConditionalProcessingAttributes
cpa,CoreAttributes
ca,PresentationAttributes
pa,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
view,Maybe Text
ar,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h,Maybe Text
pUnits,Maybe Text
pCUnits,Maybe Text
pTrans) ->
  do Text
c <- forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content -- insidePattern <- many patternContent
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (forall a. a -> Maybe a
Just Text
"") forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

patternContent :: (MonadThrow m, InputConstraints b n) => forall o. ConduitT Event o m (Maybe (Tag b n))
patternContent :: forall (m :: * -> *) b n o.
(MonadThrow m, InputConstraints b n) =>
ConduitT Event o m (Maybe (Tag b n))
patternContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [forall (m :: * -> *) b n o.
(MonadThrow m, V b ~ V2, N b ~ n, RealFloat n,
 Renderable (DImage (N b) Embedded) b, Typeable b, Typeable n) =>
ConduitT Event o m (Maybe (Tag b n))
parseImage]

-- | Parse \<filter\>, see <http://www.w3.org/TR/SVG/filters.html#FilterElement>
parseFilter :: ConduitT Event o m (Maybe (Tag b n))
parseFilter = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}filter" AttrParser
  (CoreAttributes, PresentationAttributes, XlinkAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
filterAttrs forall a b. (a -> b) -> a -> b
$
  \(CoreAttributes
ca,PresentationAttributes
pa,XlinkAttributes
xlink,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
x,Maybe Text
y,Maybe Text
w,Maybe Text
h,Maybe Text
filterRes,Maybe Text
filterUnits,Maybe Text
primUnits) ->
  do -- insideFilter <- many filterContent
     forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

filterContent :: ConduitT Event o m (Maybe (Tag b n))
filterContent = forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeGaussianBlur,
  forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeBlend,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeColorMatrix,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeComponentTransfer,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeComposite,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeConvolveMatrix, -- filter primitive elments
  forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeDiffuseLighting,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeDisplacementMap,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeFlood,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeImage,
  forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeMerge,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeMorphology,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeOffset,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeSpecularLighting,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeTile,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseFeTurbulence,
  forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseDesc,forall {m :: * -> *} {b} {o} {n}.
(MonadThrow m, Metric (V b), Floating (N b), Ord (N b)) =>
ConduitT Event o m (Maybe (Tag b n))
parseTitle]

--------------------------------------------------------------------------------------
-- filter primitives (currently only sceletons)
--------------------------------------------------------------------------------------

-- | Parse \<feBlend\>, see <http://www.w3.org/TR/SVG/filters.html#feBlendElement>
parseFeBlend :: ConduitT Event o m (Maybe (Tag b n))
parseFeBlend = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feBlend" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feBlendAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
in2,Maybe Text
mode) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feColorMatrix\>, see <http://www.w3.org/TR/SVG/filters.html#feColorMatrixElement>
parseFeColorMatrix :: ConduitT Event o m (Maybe (Tag b n))
parseFeColorMatrix = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feColorMatrix" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feColorMatrixAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
type1,Maybe Text
values) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feComponentTransfer\>, see <http://www.w3.org/TR/SVG/filters.html#feComponentTransferElement>
parseFeComponentTransfer :: ConduitT Event o m (Maybe (Tag b n))
parseFeComponentTransfer = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feComponentTransfer" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text)
feComponentTransferAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feComposite\>, see <http://www.w3.org/TR/SVG/filters.html#feCompositeElement>
parseFeComposite :: ConduitT Event o m (Maybe (Tag b n))
parseFeComposite = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feComposite" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feCompositeAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
in2,Maybe Text
operator,Maybe Text
k1,Maybe Text
k2,Maybe Text
k3,Maybe Text
k4) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feConvolveMatrix\>, see <http://www.w3.org/TR/SVG/filters.html#feConvolveMatrixElement>
parseFeConvolveMatrix :: ConduitT Event o m (Maybe (Tag b n))
parseFeConvolveMatrix = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feConvolveMatrix" AttrParser
  (CoreAttributes, Maybe Text, FilterPrimitiveAttributes, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feConvolveMatrixAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,Maybe Text
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
order,Maybe Text
km,Maybe Text
d,Maybe Text
bias,Maybe Text
tx,Maybe Text
ty,Maybe Text
em,Maybe Text
ku,Maybe Text
par) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feDiffuseLighting\>, see <http://www.w3.org/TR/SVG/filters.html#feDiffuseLightingElement>
parseFeDiffuseLighting :: ConduitT Event o m (Maybe (Tag b n))
parseFeDiffuseLighting = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feDiffuseLighting" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text)
feDiffuseLightingAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
surfaceScale,Maybe Text
diffuseConstant,Maybe Text
kuLength) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feDisplacementMap\>, see <http://www.w3.org/TR/SVG/filters.html#feDisplacementMapElement>
parseFeDisplacementMap :: ConduitT Event o m (Maybe (Tag b n))
parseFeDisplacementMap = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feDisplacementMap" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
feDisplacementMapAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
in2,Maybe Text
sc,Maybe Text
xChan,Maybe Text
yChan) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feFlood\>, see <http://www.w3.org/TR/SVG/filters.html#feFloodElement>
parseFeFlood :: ConduitT Event o m (Maybe (Tag b n))
parseFeFlood = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feFlood" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text)
feFloodAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feGaussianBlur\>, see <http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement>
parseFeGaussianBlur :: ConduitT Event o m (Maybe (Tag b n))
parseFeGaussianBlur = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feGaussianBlur" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feGaussianBlurAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
stdDeviation) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feImage\>, see <http://www.w3.org/TR/SVG/filters.html#feImageElement>
parseFeImage :: ConduitT Event o m (Maybe (Tag b n))
parseFeImage = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feImage" AttrParser
  (CoreAttributes, Maybe Text, FilterPrimitiveAttributes,
   XlinkAttributes, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feImageAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,Maybe Text
pa,FilterPrimitiveAttributes
fpa,XlinkAttributes
xlibk,Maybe Text
class_,Maybe Text
style,Maybe Text
ext,Maybe Text
par) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feMerge\>, see <http://www.w3.org/TR/SVG/filters.html#feMergeElement>
parseFeMerge :: ConduitT Event o m (Maybe (Tag b n))
parseFeMerge = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feMerge" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text)
feMergeAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feMorphology\>, see <http://www.w3.org/TR/SVG/filters.html#feMorphologyElement>
parseFeMorphology :: ConduitT Event o m (Maybe (Tag b n))
parseFeMorphology = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feMorphology" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feMorphologyAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
operator,Maybe Text
radius) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feOffset\>, see <http://www.w3.org/TR/SVG/filters.html#feOffsetElement>
parseFeOffset :: ConduitT Event o m (Maybe (Tag b n))
parseFeOffset = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feOffset" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feOffsetAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
dx,Maybe Text
dy) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feSpecularLighting\>, see <http://www.w3.org/TR/SVG/filters.html#feSpecularLightingElement>
parseFeSpecularLighting :: ConduitT Event o m (Maybe (Tag b n))
parseFeSpecularLighting = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feSpecularLighting" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text,
   Maybe Text, Maybe Text)
feSpecularLightingAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
surfaceScale,Maybe Text
sc,Maybe Text
se,Maybe Text
ku) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feTile\>, see <http://www.w3.org/TR/SVG/filters.html#feTileElement>
parseFeTile :: ConduitT Event o m (Maybe (Tag b n))
parseFeTile = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feTile" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text)
feTileAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- | Parse \<feTurbulence\>, see <http://www.w3.org/TR/SVG/filters.html#feTurbulenceElement>
parseFeTurbulence :: ConduitT Event o m (Maybe (Tag b n))
parseFeTurbulence = forall {m :: * -> *} {b} {o} {c}.
MonadThrow m =>
Name
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tagName Name
"{http://www.w3.org/2000/svg}feTurbulence" AttrParser
  (CoreAttributes, PresentationAttributes, FilterPrimitiveAttributes,
   Maybe Text, Maybe Text, Maybe Text, Maybe Text, Maybe Text)
feTurbulenceAttrs forall a b. (a -> b) -> a -> b
$
   \(CoreAttributes
ca,PresentationAttributes
pa,FilterPrimitiveAttributes
fpa,Maybe Text
class_,Maybe Text
style,Maybe Text
in1,Maybe Text
in2,Maybe Text
mode) -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall b n.
Maybe Text
-> (ViewBox n -> Path V2 n)
-> ((HashMaps b n, ViewBox n) -> Diagram b)
-> Tag b n
Leaf (CoreAttributes -> Maybe Text
id1 CoreAttributes
ca) forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

------------------------------------------------------------------------------------

animationElements :: [a]
animationElements = []