hoodle-parser 0.1.0 → 0.1.1
raw patch · 3 files changed
+73/−12 lines, 3 filesdep −attoparsec-conduitdep −conduitdep −zlib-conduitdep ~hoodle-typesdep ~lensdep ~xournal-typesPVP ok
version bump matches the API change (PVP)
Dependencies removed: attoparsec-conduit, conduit, zlib-conduit
Dependency ranges changed: hoodle-types, lens, xournal-types
API changes (from Hackage documentation)
+ Text.Hoodle.Parse.Attoparsec: svg_command :: Parser ByteString
+ Text.Hoodle.Parse.Attoparsec: svg_footer :: Parser ()
+ Text.Hoodle.Parse.Attoparsec: svg_header :: Parser ((Double, Double), Dimension)
+ Text.Hoodle.Parse.Attoparsec: svg_obj :: Parser Item
+ Text.Hoodle.Parse.Attoparsec: svg_render :: Parser ByteString
+ Text.Hoodle.Parse.Attoparsec: svg_text :: Parser ByteString
Files
- LICENSE +1/−1
- hoodle-parser.cabal +4/−7
- src/Text/Hoodle/Parse/Attoparsec.hs +68/−4
LICENSE view
@@ -1,7 +1,7 @@ The following license covers this documentation, and the source code, except where otherwise indicated. -Copyright 2011-2011, Ian-Woo Kim. All rights reserved.+Copyright 2011-2013, Ian-Woo Kim. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
hoodle-parser.cabal view
@@ -1,5 +1,5 @@ Name: hoodle-parser-Version: 0.1.0+Version: 0.1.1 Synopsis: Hoodle file parser Description: Text parser for hoodle xml file Homepage: http://ianwookim.org/hoodle@@ -25,14 +25,11 @@ attoparsec == 0.10.*, bytestring >= 0.9, containers >= 0.4, - conduit == 0.5.*, strict == 0.3.*, - attoparsec-conduit == 0.5.*,- hoodle-types >= 0.1.0, - xournal-types >= 0.5.0,+ hoodle-types >= 0.1.1, + xournal-types >= 0.5.0.1, text == 0.11.*,- lens >= 2.4, - zlib-conduit == 0.5.*+ lens >= 2.5 Exposed-Modules: Text.Hoodle.Parse.Attoparsec Text.Hoodle.Parse.Zlib
src/Text/Hoodle/Parse/Attoparsec.hs view
@@ -19,7 +19,7 @@ import Control.Applicative import Data.Attoparsec import Data.Attoparsec.Char8 ( char, decimal, double, skipSpace- , isHorizontalSpace)+ , isHorizontalSpace, anyChar) -- import qualified Data.Attoparsec.Iteratee as AI import qualified Data.ByteString.Char8 as B hiding (map) import Data.Char @@ -175,8 +175,72 @@ string "/>" (return . H.ItemImage) (H.Image fsrc (posx,posy) (H.Dim width height)) - +svg_header :: Parser ((Double,Double),H.Dimension)+svg_header = do trim + string "<svgobject"+ trim + string "x=\""+ posx <- double + char '"'+ trim+ string "y=\""+ posy <- double+ char '"'+ trim + string "width=\""+ width <- double+ char '"'+ trim + string "height=\""+ height <- double+ char '"'+ trim + string ">"+ return ((posx,posy),H.Dim width height) ++svg_footer :: Parser () +svg_footer = string "</svgobject>" >> return ()++svg_text :: Parser B.ByteString +svg_text = do + string "<text>"+ str <- string "<![CDATA[" *> manyTill anyChar (try (string "]]>"))+ string "</text>"+ return (B.pack str) ++svg_command :: Parser B.ByteString +svg_command = do + string "<command>"+ str <- string "<![CDATA[" *> manyTill anyChar (try (string "]]>"))+ string "</command>"+ return (B.pack str)++svg_render :: Parser B.ByteString +svg_render = do + string "<render>"+ str <- string "<![CDATA[" *> manyTill anyChar (try (string "]]>"))+ string "</render>"+ return (B.pack str)+++svg_obj :: Parser H.Item +svg_obj = do (xy,dim) <- svg_header+ trim + (mt,mc) <- (try (do t <- svg_text + trim + c <- svg_command + return (Just t, Just c)) + <|> try (svg_text >>= \t -> return (Just t, Nothing))+ <|> return (Nothing,Nothing))+ trim + bstr <- svg_render + trim + svg_footer+ (return . H.ItemSVG) (H.SVG mt mc bstr xy dim)++ + -- | trim :: Parser () trim = trim_starting_space@@ -212,12 +276,12 @@ layer :: Parser H.Layer layer = do trim- layerheader+ layerheader <?> "layer" trim -- s1 <- onestroke -- s2 <- img -- let strokes = [s1,s2]- itms <- many (try onestroke <|> img)+ itms <- many (try onestroke <|> try img <|> svg_obj) trim layerclose return $ H.Layer itms