packages feed

gridtables 0.1.1.0 → 0.1.1.1

raw patch · 4 files changed

+77/−17 lines, 4 filesdep ~containersnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: containers

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,21 @@  `gridtables` uses [PVP Versioning][]. +## gridtables-0.1.1.1++-   Fix a bug in computing table alignments with colspans (#3).+    If a header cell with colspans has an alignment, that+    alignment is given to all the columns spanned instead of+    just the first.++-   Bump version bound for doclayout.++-   Remove call to partial function `tail`.++-   Allow containers 0.8.++-   Fix list of tested GHC versions in cabal file.+ ## gridtables-0.1.1.0  Released 2025-09-22.
gridtables.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                gridtables-version:             0.1.1.0+version:             0.1.1.1 synopsis:            Parser for reStructuredText-style grid tables. description:         Provides a parser for plain-text representations of                      tables. This package supports table headers, cells@@ -12,15 +12,19 @@ license-file:        LICENSE author:              Albert Krewinkel maintainer:          Albert Krewinkel <albert@zeitkraut.de>-copyright:           © 2022-2023 Posit Software, PBC+copyright:           © 2022-2026 Posit Software, PBC category:            Text extra-doc-files:     README.md                    , CHANGELOG.md-tested-with:         GHC == 8.6.5-                     GHC == 8.8.4-                     GHC == 8.10.7-                     GHC == 9.0.2-                     GHC == 9.2.2+tested-with:         GHC == 8.10.7+                   , GHC == 9.0+                   , GHC == 9.2+                   , GHC == 9.4+                   , GHC == 9.6+                   , GHC == 9.8+                   , GHC == 9.10+                   , GHC == 9.12+                   , GHC == 9.14  source-repository head   type:                git@@ -56,8 +60,8 @@ library   import:              common-options   hs-source-dirs:      src-  build-depends:       containers            >= 0.6      && < 0.8-                     , doclayout             >= 0.4      && < 0.6+  build-depends:       containers            >= 0.6      && < 0.9+                     , doclayout             >= 0.4      && < 0.7   exposed-modules:     Text.GridTable                      , Text.GridTable.ArrayTable                      , Text.GridTable.Parse
src/Text/GridTable/Trace.hs view
@@ -27,7 +27,7 @@ import Data.Array.ST import Data.Function (on) import Data.List (foldl')-import Data.Maybe (fromMaybe)+import Data.Maybe (fromMaybe, listToMaybe) import Data.Set (Set) import Data.Text (Text) import Text.DocLayout (charWidth, realLength)@@ -411,14 +411,19 @@       colseps = Set.toAscList $ gridColSeps traceInfo       rowindex = Map.fromList $ zip rowseps [1..]       colindex = Map.fromList $ zip colseps [1..]-      colwidths = [ b - a - 1 | (b, a) <- zip (tail colseps) colseps ]+      colwidths = [ b - a - 1 | (b, a) <- zip (drop 1 colseps) colseps ]+      alignSpecs = case partSeps of+                     partSep:_ -> partSepColSpec partSep+                     []        -> fromMaybe [] colSpecsFirstLine+      -- A segment of the alignment line may span multiple columns;+      -- each column gets the alignment of the segment containing it.+      alignFor (left, right) = fromMaybe AlignDefault $ listToMaybe+        [ colAlign cs | cs <- alignSpecs+                      , colStart cs - 1 <= left+                      , right <= colEnd cs ]       colSpecs = zip-                 (map colAlign-                   (case partSeps of-                       partSep:_ -> partSepColSpec partSep-                       []        -> fromMaybe [] colSpecsFirstLine)-                   ++ repeat AlignDefault)-                 (map fromCharCol colwidths)+                  (map alignFor (zip colseps (drop 1 colseps)))+                  (map fromCharCol colwidths)       lastCol = ColIndex (length colwidths)       mlastLine = Set.lookupMax (gridRowSeps traceInfo)       tableHead = case partSeps of
test/test-gridtables.hs view
@@ -528,6 +528,42 @@                      , [Cell "3" 1 1]                      ]     ]+  , testGroup "markers spanning multiple columns"+    [ testCase "marker in first line" $+      let gt = T.unlines+               [ "+:------------:+---------------:+"+               , "| Heading 1    | Heading 2      |"+               , "+---+----+-----+----+------+----+"+               , "| A | B  | C   | D  |  E   | F  |"+               , "+---+----+-----+----+------+----+"+               ]+      in arrayTableColSpecs <$> parse' gridTable gt @?=+         Right (listArray (1, 6)+                [ (AlignCenter, 3)+                , (AlignCenter, 4)+                , (AlignCenter, 5)+                , (AlignRight, 4)+                , (AlignRight, 6)+                , (AlignRight, 4)+                ])++    , testCase "marker in part separator" $+      let gt = T.unlines+               [ "+-------------+-------+"+               , "| head        | c     |"+               , "+:===========:+======:+"+               , "| ab          | c     |"+               , "+------+------+-------+"+               , "| a    | b    | c     |"+               , "+------+------+-------+"+               ]+      in arrayTableColSpecs <$> parse' gridTable gt @?=+         Right (listArray (1, 3)+                [ (AlignCenter, 6)+                , (AlignCenter, 6)+                , (AlignRight, 7)+                ])+    ]   ]  defaultAlign :: [Int] -> Array ColIndex (Alignment, Int)