From c9daf8d3187359497f19c1d1828065a52a335e68 Mon Sep 17 00:00:00 2001 From: Masao Uebayashi Date: Mon, 6 Jul 2020 13:57:38 +0900 Subject: [PATCH 1/3] Test shorthand arc --- test/PathParserSpec.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/PathParserSpec.hs b/test/PathParserSpec.hs index 3954cf6..28f1925 100644 --- a/test/PathParserSpec.hs +++ b/test/PathParserSpec.hs @@ -10,9 +10,20 @@ import Test.Hspec spec :: Spec spec = do - describe "num" $ do + describe "num" $ it "support shorthand number" $ do - parseOnly command d `shouldBe` Right p - where + let d = "M-.10 .10z" p = MoveTo OriginAbsolute [V2 (-0.1) 0.10] + parseOnly command d `shouldBe` Right p + describe "arc" $ do + it "support arc" $ do + let + d = "a.5 .5 .5 0 0 -.5 .5" + p = EllipticalArc OriginRelative [(0.5, 0.5, 0.5, False, False, V2 (-0.5) 0.5)] + parseOnly command d `shouldBe` Right p + it "support shorthand arc" $ do + let + d = "a.5 .5 .5 00-.5 .5" + p = EllipticalArc OriginRelative [(0.5, 0.5, 0.5, False, False, V2 (-0.5) 0.5)] + parseOnly command d `shouldBe` Right p From cb8d55c16f88b36fe1fa657da9f35b8265cd4b5c Mon Sep 17 00:00:00 2001 From: Masao Uebayashi Date: Mon, 6 Jul 2020 14:17:49 +0900 Subject: [PATCH 2/3] Handle bool --- src/Graphics/Svg/PathParser.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Graphics/Svg/PathParser.hs b/src/Graphics/Svg/PathParser.hs index 4c6cf5b..6e15921 100644 --- a/src/Graphics/Svg/PathParser.hs +++ b/src/Graphics/Svg/PathParser.hs @@ -50,6 +50,11 @@ num = realToFrac <$> (skipSpace *> plusMinus <* skipSpace) shorthand = process' <$> (string "." *> many1 digit) process' = either (const 0) id . parseOnly doubleNumber . T.pack . (++) "0." +bool :: Parser Bool +bool = ("1" ==) <$> (skipSpace *> zeroOrOne <* skipSpace) + where zeroOrOne = string "0" <|> string "1" + + viewBoxParser :: Parser (Double, Double, Double, Double) viewBoxParser = (,,,) <$> iParse <*> iParse <*> iParse <*> iParse @@ -102,11 +107,12 @@ command = (MoveTo OriginAbsolute <$ string "M" <*> pointList) manyComma a = a `sepBy1` commaWsp numComma = num <* commaWsp + boolComma = bool <* commaWsp ellipticalArgs = (,,,,,) <$> numComma <*> numComma <*> numComma - <*> (fmap (/= 0) numComma) - <*> (fmap (/= 0) numComma) + <*> boolComma + <*> boolComma <*> point serializePoint :: RPoint -> String From 62dcc2d1237224d2df2b6cd8e6d978d0be4be922 Mon Sep 17 00:00:00 2001 From: Masao Uebayashi Date: Mon, 14 Dec 2020 17:45:18 +0900 Subject: [PATCH 3/3] Local version --- svg-tree.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svg-tree.cabal b/svg-tree.cabal index 002d39a..d88c872 100644 --- a/svg-tree.cabal +++ b/svg-tree.cabal @@ -1,5 +1,5 @@ name: svg-tree -version: 0.6.2.4 +version: 0.6.2.4.999 synopsis: SVG file loader and serializer description: svg-tree provides types representing a SVG document,