align-equal 0.1.1.1 → 1.0.0.0
raw patch · 3 files changed
+55/−28 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Text.AlignEqual: prefixLength :: Text -> Int
+ Data.Text.AlignEqual: prefixLength :: Text -> Maybe Int
Files
- CHANGELOG.md +33/−14
- align-equal.cabal +1/−1
- src/Data/Text/AlignEqual.hs +21/−13
CHANGELOG.md view
@@ -1,32 +1,51 @@ # Changelog All notable changes to the `align-equal` project will be documented in this file. +## [1.0.0] - 2025-03-31++### Changed:+- **`prefixLength`**: Changed return type from `Int` to `Maybe Int`. Now returns `Nothing` if no '=' is found, and `Just` the length of the prefix before the first '=' if it exists. This is a breaking change.+- Updated documentation for **`prefixLength`** and **`adjustText`** to reflect the new behavior.+- Bumped package version to `1.0.0` to reflect a breaking change in the API.++### Fixed:+- Properly handles lines without '=' in **`adjustText`** and **`prefixLength`**.+ ## [0.1.1.1] - 2025-03-31-### Added -- Expanded `README.md` with a detailed description of the tool. -- Included Vim usage instructions with examples. -### Miscellaneous -- Bumped version to `0.1.1.1` in `align-equal.cabal`. +### Added:+- Expanded `README.md` with a detailed description of the tool.+- Included Vim usage instructions with examples. +### Miscellaneous:+- Bumped version to `0.1.1.1` in `align-equal.cabal`.+ ## [0.1.1.0] - 2025-03-27-- **Added**: Extracted core functions into a separate library module (`Data.Text.AlignEqual`).++### Added:+- Extracted core functions into a separate library module (`Data.Text.AlignEqual`). - Refactored original `Main.hs` into executable and library components. - Added `src/Data/Text/AlignEqual.hs` with core text alignment logic. - Updated `app/Main.hs` to import and use `Data.Text.AlignEqual`. - Adjusted `.cabal` file to include a new library section and dependencies.-- **Added**: Haddock documentation for `Data.Text.AlignEqual`.+- Added Haddock documentation for `Data.Text.AlignEqual`. - Documented module purpose, `prefixLength`, `adjustLine`, and `adjustText` with descriptions, examples, and parameter annotations.-- **Added**: Included `CHANGELOG.md` in the package documentation via `extra-doc-files` in `.cabal`.-- **Maintained**: Compatibility with the existing executable.+- Included `CHANGELOG.md` in the package documentation via `extra-doc-files` in `.cabal`.+- Maintained compatibility with the existing executable. ## [0.1.0.1] - 2025-03-10-- **Fixed**: Relaxed `base` dependency constraint to `>=4.17 && <4.19`.-- **Fixed**: Removed duplicate `extra-doc-files` entry in `.cabal` file.-- **Added**: `README.md` with credit to Gabriella Gonzalez.-- **Added**: Source repository link to `hub.darcs.net` in `.cabal` file. +### Fixed:+- Relaxed `base` dependency constraint to `>=4.17 && <4.19`.+- Removed duplicate `extra-doc-files` entry in `.cabal` file.++### Added:+- `README.md` with credit to Gabriella Gonzalez.+- Source repository link to `hub.darcs.net` in `.cabal` file.+ ## [0.1.0.0] - 2025-03-10-- **Initial Release**: Basic functionality for aligning text with equal signs.++### Initial Release:+- Basic functionality for aligning text with equal signs. - Implemented as a standalone executable in `Main.hs`. - Initial project setup with `.cabal` and `LICENSE` files.
align-equal.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: align-equal-version: 0.1.1.1+version: 1.0.0.0 license: MIT license-file: LICENSE author: Joonkyu Park (based on original work by Gabriella Gonzalez)
src/Data/Text/AlignEqual.hs view
@@ -3,28 +3,33 @@ -- | A module providing functions for text alignment and padding. module Data.Text.AlignEqual where -import Data.Text (Text)-import qualified Data.Text as T-import Safe+import Data.Maybe (catMaybes)+import Data.Text (Text)+import qualified Data.Text as T+import Safe (maximumMay) -- | Calculates the number of characters preceding the first '=' sign in a text line.+-- If no '=' is found, returns `Nothing`. If '=' is found, returns `Just` the length of the prefix before it. -- -- >>> prefixLength "key=value"--- 3+-- Just 3 -- >>> prefixLength "a=b"--- 1+-- Just 1 -- >>> prefixLength "noequals"--- 8+-- Nothing prefixLength :: Text -- ^ The input text line- -> Int- -- ^ The number of characters before the first '=' sign-prefixLength line = T.length prefix+ -> Maybe Int+ -- ^ The number of characters before the first '=' sign, or `Nothing` if no '=' is found, or `Just` the length otherwise+prefixLength line =+ if T.null suffix+ then Nothing+ else Just (T.length prefix) where- (prefix, _) = T.breakOn "=" line+ (prefix, suffix) = T.breakOn "=" line --- | Adjusts the prefix of a text line to a desired length by adding padding.+-- | Adjusts the prefix of a text line to a desired length by adding padding spaces. -- -- >>> adjustLine 5 "key=value" -- "key =value"@@ -50,7 +55,8 @@ newLine = T.concat [ prefix, spaces, suffix ] -- | Processes multi-line text to align all '=' signs across lines.--- Adjusts the prefix length of each line to match the maximum prefix length.+-- It adjusts the prefix length of each line to match the maximum prefix length.+-- If a line does not contain '=', it will be left as-is. -- -- >>> adjustText "key=value\na=b" -- "key=value\na =b"@@ -67,8 +73,10 @@ prefixLengths = map prefixLength oldLines + prefixLengths' = catMaybes prefixLengths+ newLines =- case maximumMay prefixLengths of+ case maximumMay prefixLengths' of Nothing -> [] Just desiredPrefixLength ->