palmeiralabs/swifttexttoolkit
**SwiftTextToolkit** is a lightweight and modular Swift package that provides utilities for working with text in iOS and other Swift-based platforms. It includes tools to count words and characters, and to generate slugs from strings.
β¨ Features
WordCounter: Count words and characters in a string, ignoring whitespace and newlines.Slugifier: Create slugs from text with three levels of aggressiveness:
- Fast (basic replacement) - Moderate (whitespace-aware) - Advanced (URL-friendly and cleaned)
- Fully documented with DocC.
- Built using Swift Package Manager.
- 100% Swift-native and unit-tested.
π¦ Installation
Using Swift Package Manager
In your Package.swift file, add:
dependencies: [
.package(url: "https://github.com/PalmeiraLabs/SwiftTextToolkit.git", from: "1.0.0")
]Or from Xcode:
File β Add Packages β Paste the GitHub repository URL
π Example Usage
import SwiftTextToolkit
let toolkit = SwiftTextToolkit()
let text = "Hello, Swift world!"
let wordCount = toolkit.wordCounter.countWords(in: text)
// β 3
let slug = toolkit.slugifier.slugifyModerate(text: text)
// β "hello,-swift-world!"π Documentation
Generated with DocC
π¦ Download offline documentation: SwiftTextToolkit.doccarchive
π§ͺ Running Tests
This package includes unit tests for all major features. Run tests with:
swift testπͺͺ License
This project is licensed under a limited MIT-style license:
- Free to use for personal or commercial purposes.
- Modification and redistribution of modified versions are not allowed.
- Provided without any warranties.
See the LICENSE file for more information.
β οΈ Disclaimer
This software is provided "as is", without any express or implied warranties. This means:
- No guarantee it works perfectly or without bugs.
- The author is not responsible for any damage or loss caused by its use.
- You use this package at your own risk.
We recommend thorough testing before using it in critical projects.
Package Metadata
Repository: palmeiralabs/swifttexttoolkit
Default branch: main
README: README.md