https://github.com/rpearce/slugger
Clean URI slugs for Haskell
https://github.com/rpearce/slugger
Last synced: 5 months ago
JSON representation
Clean URI slugs for Haskell
- Host: GitHub
- URL: https://github.com/rpearce/slugger
- Owner: rpearce
- License: bsd-3-clause
- Created: 2021-06-23T03:34:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T11:42:56.000Z (10 months ago)
- Last Synced: 2025-07-21T23:59:57.823Z (5 months ago)
- Language: Haskell
- Homepage: https://github.com/rpearce/slugger
- Size: 125 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# slugger
Clean URI slugs for Haskell
Convert multi-language text to a US-ASCII, lowercase, hyphenated, URI-friendly "slug".
[](https://builtwithnix.org)
## Usage
### Library
There are `Data.Text` and `Data.String` library interfaces to `slugger` that
have plenty of examples in [`the test file`](./test/SluggerTest.hs), and here
are some simple examples.
Example of `Data.String.Slugger`:
```haskell
import qualified Data.String.Slugger as SluggerString
SluggerString.toSlug "Hey there, world!"
-- "hey-there-world"
SluggerString.toSlug "GARÇON - déjà , Forêt — Zoë"
-- "garcon-deja-foret-zoe"
```
Example of `Data.Text.Slugger`:
```haskell
import qualified Data.Text as T
import qualified Data.Text.Slugger as SluggerText
SluggerText.toSlug (T.pack "Hey there, world!")
-- "hey-there-world"
SluggerText.toSlug (T.pack "GARÇON - déjà , Forêt — Zoë")
-- "garcon-deja-foret-zoe"
```
### Executable
```sh
λ slugger "Hey there, world!"
hey-there-world
λ slugger "Pijamalı hasta yağız şoföre çabucak güvendi"
pijamali-hasta-yagiz-sofore-cabucak-guvendi
```
## Language Support
These are the languages that are currently tested and therefore marked as
supported. Contributions are welcome for more extensive tests or tests for
additional languages.
* Dansk (Danish)
* Deutsch (German)
* English
* Español (Spanish)
* Français (French)
* Íslenska (Icelandic)
* Italiano (Italian)
* Polski (Polish)
* Suomi (Finnish)
* Svenska (Swedish)
* Türkçe (Turkish)
## Development
Try the project executable via a nix flake app:
```sh
λ nix run . "Testing 1,2,3"
testing-1-2-3
```
Get into a nix dev environment:
```sh
λ nix develop
[nix]λ
```
Build the project:
```sh
[nix]λ nix build
```
Run the tests from the shell:
```sh
[nix]λ cabal test --test-show-details=streaming --test-option=--color
```
Run the tests from GHCi:
```sh
[nix]λ cabal repl slugger-test
[ghci]λ :main
# test output prints here
# make some changes, then...
[ghci]λ :reload
[ghci]λ :main
```