packages feed

symantic-document 1.2.2.20190627 → 1.2.3.20190628

raw patch · 3 files changed

+31/−13 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Symantic.Document.Plain: newlineJustifying :: Spaceable d => Plain d

Files

Symantic/Document/Plain.hs view
@@ -65,7 +65,7 @@    -- ^ The 'Width' of the 'plainState_buffer' so far.  , plainState_removableIndent :: !Indent    -- ^ The amount of 'Indent' added by 'breakspace'-   -- that can be removed by breaking the 'space' into a 'newline'.+   -- that can be removed by breaking the 'space' into a 'newlineJustifying'.  } deriving (Show)  defPlainState :: PlainState d@@ -148,14 +148,18 @@ 	mempty = Plain $ \_inh st k -> k (id,st) 	mappend = (<>) instance Spaceable d => Spaceable (Plain d) where+	-- | The default 'newline' does not justify+	-- 'plainState_buffer', for that use 'newlineJustifying'. 	newline = Plain $ \inh st k -> 		k(\next ->-			(if plainInh_justify inh then joinLine inh st else mempty) <>+			(if plainInh_justify inh+				then joinPlainLine $ List.reverse $ plainState_buffer st+				else mempty) <> 			newline<>spaces (plainInh_indent inh)<>next 		 , st-			 { plainState_bufferStart      = plainInh_indent inh-			 , plainState_bufferWidth      = 0-			 , plainState_buffer           = mempty+			 { plainState_bufferStart = plainInh_indent inh+			 , plainState_bufferWidth = 0+			 , plainState_buffer      = mempty 			 } 		 ) 	space = spaces 1@@ -274,9 +278,8 @@  -- | Commit 'plainState_buffer' upto there, so that it won't be justified. flushLine :: Spaceable d => Plain d-flushLine = Plain $ \_inh st ok ->-	ok-	 ( (joinPlainLine (collapseSpaces <$> List.reverse (plainState_buffer st)) <>)+flushLine = Plain $ \_inh st k ->+	k( (joinPlainLine (collapseSpaces <$> List.reverse (plainState_buffer st)) <>) 	 , st 		 { plainState_bufferStart = plainState_bufferStart st + plainState_bufferWidth st 		 , plainState_bufferWidth = 0@@ -302,7 +305,7 @@ 		 ) 		 fits 		 {-overflow-}(\_r ->-			unPlain newline inh st k+			unPlain newlineJustifying inh st k 			 fits 			 {-overflow-}( 				if plainState_removableIndent st < newlineInd@@ -327,7 +330,7 @@ 		 ) 		 fits 		 {-overflow-}(\_r ->-			unPlain newline inh st k+			unPlain newlineJustifying inh st k 			 fits 			 {-overflow-}( 				if plainState_removableIndent st < newlineInd@@ -340,6 +343,20 @@ 		 {-overflow-}(\_r -> 			unPlain y inh st k fits overflow 		 )++-- | Like 'newline', but justify 'plainState_buffer' before.+newlineJustifying :: Spaceable d => Plain d+newlineJustifying = Plain $ \inh st k ->+	k(\next ->+		(if plainInh_justify inh then joinLine inh st else mempty) <>+		newline<>spaces (plainInh_indent inh)<>next+	 , st+		 { plainState_bufferStart = plainInh_indent inh+		 , plainState_bufferWidth = 0+		 , plainState_buffer      = mempty+		 }+	 )+ -- String instance (From (Word String) d, Spaceable d) =>          From String (Plain d) where
symantic-document.cabal view
@@ -2,7 +2,7 @@ -- PVP:  +-+------- breaking API changes --       | | +----- non-breaking API additions --       | | | +--- code changes with no API change-version: 1.2.2.20190627+version: 1.2.3.20190628 category: Text synopsis: Document symantics. description: Symantics for generating documents.
test/HUnit.hs view
@@ -114,9 +114,11 @@  , 10 `maxWidth` "__" <> align (justify "1 2 3 4 5") ==> "__1 2  3 4\n  5"  -- justify does not overflow the alignment  , 10 `maxWidth` justify (nestedAlign 6) ==> "1 2 3 4 5\n         6"- , 10 `maxWidth` justify ("a b\n" <> nestedAlign 2) ==> "a        b\n1 2"+ , 10 `maxWidth` justify ("a b c de " <> nestedAlign 2) ==> "a b  c  de\n1 2"  , 10 `maxWidth` justify (bold ("12 34 56 78 "<> underline "90" <> " 123 456  789"))    ==> "\ESC[1m12  34  56\n78 \ESC[4m90\ESC[0;1m  123\n456 789\ESC[0m"+ -- justify does not justify on explicit newlines+ , 10 `maxWidth` justify "1 2 3 4 5 6 7\n8 9 1 2 3 4 5" ==> "1 2  3 4 5\n6 7\n8 9  1 2 3\n4 5"  -- align flushes the buffer  , 10 `maxWidth` justify (ul ["1 2 3 4 5 6 7 8 9"])    ==> "- 1 2  3 4\n\@@ -319,4 +321,3 @@ fun :: IsString d => Indentable d => Wrappable d => d -> d fun d = "function(" <> incrIndent 2 (breakalt d (newline<>d<>newline)) <> ")" -t1 = 10 `maxWidth` justify (let i = "1 2 3 4 5 6 7 8 9" in ol [ol [i, i], ol [i, i]])