gridtables 0.1.0.0 → 0.1.1.0
raw patch · 8 files changed
+53/−21 lines, 8 filesdep ~arraydep ~containersdep ~doclayoutPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: array, containers, doclayout
API changes (from Hackage documentation)
- Text.GridTable: gridTable :: Stream s m Char => ParsecT s u m (ArrayTable [Text])
+ Text.GridTable: gridTable :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m (ArrayTable [Text])
- Text.GridTable.Parse: gridTable :: Stream s m Char => ParsecT s u m (ArrayTable [Text])
+ Text.GridTable.Parse: gridTable :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m (ArrayTable [Text])
- Text.GridTable.Parse: tableLine :: Stream s m Char => ParsecT s u m Text
+ Text.GridTable.Parse: tableLine :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Text
Files
- CHANGELOG.md +14/−1
- LICENSE +1/−1
- gridtables.cabal +6/−6
- src/Text/GridTable.hs +1/−1
- src/Text/GridTable/ArrayTable.hs +1/−1
- src/Text/GridTable/Parse.hs +1/−1
- src/Text/GridTable/Trace.hs +4/−3
- test/test-gridtables.hs +25/−7
CHANGELOG.md view
@@ -2,9 +2,22 @@ `gridtables` uses [PVP Versioning][]. +## gridtables-0.1.1.0++Released 2025-09-22.++- Fixed length calculation for combined characters (Tuong Nguyen+ Manh).++- Updated upper bound on text.++- Minor code and docs improvements.++- Added version bounds to all build dependencies.+ ## gridtables-0.1.0.0 -Release pending.+Released 2022-09-30. - Added support for table foots.
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright © 2022 RStudio, PBC+Copyright © 2022-2023 Posit Software, PBC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
gridtables.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: gridtables-version: 0.1.0.0+version: 0.1.1.0 synopsis: Parser for reStructuredText-style grid tables. description: Provides a parser for plain-text representations of tables. This package supports table headers, cells@@ -12,7 +12,7 @@ license-file: LICENSE author: Albert Krewinkel maintainer: Albert Krewinkel <albert@zeitkraut.de>-copyright: © 2022 RStudio, PBC+copyright: © 2022-2023 Posit Software, PBC category: Text extra-doc-files: README.md , CHANGELOG.md@@ -28,9 +28,9 @@ common common-options build-depends: base >= 4.12 && < 5- , array+ , array >= 0.5 && < 0.6 , parsec >= 3.1 && < 3.2- , text >= 1.1.1.0 && < 1.3 || >= 2.0 && < 2.1+ , text >= 1.1.1.0 && < 1.3 || >= 2.0 && < 2.2 default-language: Haskell2010 default-extensions: OverloadedStrings other-extensions: FlexibleContexts@@ -56,8 +56,8 @@ library import: common-options hs-source-dirs: src- build-depends: containers- , doclayout+ build-depends: containers >= 0.6 && < 0.8+ , doclayout >= 0.4 && < 0.6 exposed-modules: Text.GridTable , Text.GridTable.ArrayTable , Text.GridTable.Parse
src/Text/GridTable.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE RankNTypes #-} {- | Module : Text.GridTable-Copyright : © 2022 Albert Krewinkel+Copyright : © 2022-2023 Posit Software, PBC License : MIT Maintainer : Albert Krewinkel <albert@zeitkraut.de>
src/Text/GridTable/ArrayTable.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE LambdaCase #-} {- | Module : Text.GridTable.ArrayTable-Copyright : © 2022 RStudio, PBC+Copyright : © 2022-2023 Posit Software, PBC License : MIT Maintainer : Albert Krewinkel <albert@zeitkraut.de>
src/Text/GridTable/Parse.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {- | Module : Text.GridTable-Copyright : © 2022 Albert Krewinkel+Copyright : © 2022-2023 Posit Software, PBC License : MIT Maintainer : Albert Krewinkel <albert@zeitkraut.de>
src/Text/GridTable/Trace.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE RankNTypes #-} {- | Module : Text.GridTable.Trace-Copyright : © 2022 Albert Krewinkel+Copyright : © 2022-2023 Posit Software, PBC License : MIT Maintainer : Albert Krewinkel <albert@zeitkraut.de> @@ -30,7 +30,7 @@ import Data.Maybe (fromMaybe) import Data.Set (Set) import Data.Text (Text)-import Text.DocLayout (charWidth)+import Text.DocLayout (charWidth, realLength) import Text.GridTable.ArrayTable import qualified Data.Map.Strict as Map import qualified Data.Set as Set@@ -99,7 +99,7 @@ -- | Converts a list of lines into a char array. toCharGrid :: [Text] -> CharGrid toCharGrid lines =- let chars = foldr (\t m -> max m (T.length t)) 0 lines -- potential overcount+ let chars = foldr (\t m -> max m (realLength t)) 0 lines -- potential overcount gbounds = ( (CharRow 1, CharCol 1) , (CharRow (length lines), CharCol chars) )@@ -344,6 +344,7 @@ lastRow :: CharGrid -> CharRow lastRow = fst . snd . bounds +-- | Forgiving version of scanRight, allowing misaligned line ends scanRightRestOfLine :: CharGrid -> CharIndex -> CharRow -> Maybe ColSeps scanRightRestOfLine charGrid (_top, left) bottom = let go :: CharCol -> Maybe ColSeps -> Maybe ColSeps
test/test-gridtables.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TupleSections #-} {-| Module : Main-Copyright : © 2022 Albert Krewinkel+Copyright : © 2022-2023 Posit Software, PBC License : MIT Maintainer : Albert Krewinkel <albert+hslua@zeitkraut.de> @@ -27,17 +28,17 @@ ] parse' :: ParsecT Text () Identity a -> Text -> Either ParseError a-parse' p t = runParser p () "<test input>" t+parse' p = runParser p () "<test input>" -- | Test parsing into lines linesTests :: TestTree linesTests = testGroup "lines" [ testCase "get lines" $ parse' (many1 tableLine) "| one | two |\n| three |\n| four |\n"- @?= Right ([ "| one | two |"- , "| three |"- , "| four |"- ])+ @?= Right [ "| one | two |"+ , "| three |"+ , "| four |"+ ] , testCase "fail if not a table" $ parse' (many tableLine) "nope\nnada\n" @?= Right []@@ -372,6 +373,23 @@ , arrayTableColSpecs = defaultAlign [10, 1] }) + , testCase "combined characters" $+ let gt = T.unlines+ [ "+---+------+"+ , "| a | back |"+ , "+===+======+"+ , "| ø̞ | o̞ |"+ , "+---+------+"+ ]+ in parse' gridTable gt @?=+ Right (ArrayTable + { arrayTableCells = listArray ((1,1),(2,2))+ [ ContentCell 1 1 [" a "], ContentCell 1 1 [" back "], ContentCell 1 1 [" ø̞ "], ContentCell 1 1 [" o̞ "]]+ , arrayTableHead = Just 1+ , arrayTableFoot = Nothing+ , arrayTableColSpecs = defaultAlign [3, 6]+ })+ ] , testCase "unterminated row" $@@ -514,4 +532,4 @@ defaultAlign :: [Int] -> Array ColIndex (Alignment, Int) defaultAlign widths = listArray (1, ColIndex (length widths))- $ map (\w -> (AlignDefault, w)) widths+ $ map (AlignDefault,) widths