xournal-builder 0.1.1 → 0.1.1.1
raw patch · 3 files changed
+25/−13 lines, 3 filesdep ~xournal-types
Dependency ranges changed: xournal-types
Files
- CHANGES +4/−2
- src/Text/Xournal/Builder.hs +18/−8
- xournal-builder.cabal +3/−3
CHANGES view
@@ -1,4 +1,6 @@ 0.1: 18 Dec 2011 * First public release. -- +0.1.1: 12 Feb 2012+ * variable width stroke support+0.1.1.1: 3 Sep 2012+ * fix duplicated (<>) problem with Data.Monoid in base>4.5
src/Text/Xournal/Builder.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP, OverloadedStrings #-} ----------------------------------------------------------------------------- -- |@@ -14,35 +14,44 @@ module Text.Xournal.Builder where -import Data.Xournal.Simple+-- from other packages import qualified Data.ByteString as S import qualified Data.ByteString.Lazy as L import Blaze.ByteString.Builder import Blaze.ByteString.Builder.Char8 (fromChar, fromString) import Data.Double.Conversion.ByteString -import Data.Monoid+#if MIN_VERSION_base(4,5,0) +import Data.Monoid hiding ((<>)) +#else+import Data.Monoid +#endif import Data.Strict.Tuple+-- from this package +import Data.Xournal.Simple infixl 4 <> +-- | (<>) :: Monoid a => a -> a -> a (<>) = mappend -+-- | builder :: Xournal -> L.ByteString builder = toLazyByteString . fromXournal +-- | fromXournal :: Xournal -> Builder fromXournal xoj = fromByteString "<?xml version=\"1.0\" standalone=\"no\"?>\n<xournal version=\"0.4.2.1\">\n" <> fromTitle (xoj_title xoj) <> mconcat (map fromPage (xoj_pages xoj)) <> fromByteString "</xournal>\n" +-- | fromTitle :: S.ByteString -> Builder fromTitle title = fromByteString "<title>" <> fromByteString title <> fromByteString "</title>\n" - +-- | fromPage :: Page -> Builder fromPage page = fromByteString "<page width=\"" <> fromByteString (toFixed 2 w)@@ -54,6 +63,7 @@ <> fromByteString "</page>\n" where Dim w h = page_dim page +-- | fromBackground :: Background -> Builder fromBackground bkg = case bkg of @@ -80,12 +90,13 @@ <> fromString (show pageno) <> fromByteString "\"/>\n" -+-- | fromLayer :: Layer -> Builder fromLayer layer = fromByteString "<layer>\n" <> mconcat (map fromStroke (layer_strokes layer)) <> fromByteString "</layer>\n" +-- | fromStroke :: Stroke -> Builder fromStroke stroke@(Stroke _ _ _ _) = fromByteString "<stroke tool=\""@@ -109,7 +120,6 @@ <> fromByteString "\n</stroke>\n" -- | - from2DCoord :: Pair Double Double -> Builder from2DCoord (x :!: y) = fromByteString (toFixed 2 x) <> fromChar ' ' @@ -117,13 +127,13 @@ <> fromChar ' ' -- | - xyFrom3DCoord :: (Double,Double,Double) -> Builder xyFrom3DCoord (x,y,_) = fromByteString (toFixed 2 x) <> fromChar ' ' <> fromByteString (toFixed 2 y) <> fromChar ' ' +-- | zFrom3DCoord :: (Double,Double,Double) -> Builder zFrom3DCoord (_,_,z) = fromByteString (toFixed 2 z) <> fromChar ' '
xournal-builder.cabal view
@@ -1,5 +1,5 @@ Name: xournal-builder-Version: 0.1.1+Version: 0.1.1.1 Synopsis: text builder for xournal file format Description: This library builds text xoj format file from xournal data structure License: BSD3@@ -16,11 +16,11 @@ Library hs-source-dirs: src- ghc-options: -Wall -funbox-strict-fields -fno-warn-unused-do-bind+ ghc-options: -Wall -funbox-strict-fields -fno-warn-unused-do-bind -fno-warn-orphans ghc-prof-options: -caf-all -auto-all Build-Depends: base == 4.*,- xournal-types == 0.4.*,+ xournal-types >= 0.4 && < 0.4.1, blaze-builder == 0.3.*, strict == 0.3.*, double-conversion == 0.2.*,