slugger: Clean URI slugs for Haskell

[ bsd3, data, library, program, text, web ] [ Propose Tags ]

Convert multi-language text to a US-ASCII, lowercase, hyphenated, URI-friendly "slug"


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
dev

Use development settings

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.8 && <5), slugger, text (>=1 && <1.3), text-icu (>=0.7 && <0.8) [details]
License BSD-3-Clause
Copyright 2021 Robert W. Pearce
Author Robert W. Pearce <me@robertwpearce.com>
Maintainer Robert W. Pearce <me@robertwpearce.com>
Category Data, Text, Web
Home page https://github.com/rpearce/slugger
Bug tracker https://github.com/rpearce/slugger/issues
Source repo head: git clone git://github.com/rpearce/slugger.git
Uploaded by robertwpearce at 2021-07-28T04:00:45Z
Distributions NixOS:0.1.0.1
Executables slugger
Downloads 169 total (4 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-07-28 [all 1 reports]

Readme for slugger-0.1.0.1

[back to package description]

slugger

Clean URI slugs for Haskell

Convert multi-language text to a US-ASCII, lowercase, hyphenated, URI-friendly "slug".

built with nix

Usage

Library

There are Data.Text and Data.String library interfaces to slugger that have plenty of examples in the test file, and here are some simple examples.

Example of Data.String.Slugger:

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:

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

λ 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)
  • Deutsche (German)
  • English
  • Español (Spanish)
  • Français (French)
  • Íslenskur (Icelandic)
  • Polskie (Polish)
  • Svenska (Swedish)
  • Türk (Turkish)

Development

Try the project executable via a nix flake app:

λ nix run . "Testing 1,2,3"
testing-1-2-3

Get into a nix dev environment:

λ nix develop
[nix]λ

Build the project:

[nix]λ nix build

Run the tests from the shell:

[nix]λ cabal test --test-show-details=streaming --test-option=--color

Run the tests from GHCi:

[nix]λ cabal repl slugger-test
[ghci]λ :main
# test output prints here

# make some changes, then...
[ghci]λ :reload
[ghci]λ :main