MyNixOS website logo
Description

Clean URI slugs for Haskell.

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

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)
  • 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:

λ 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
Metadata

Version

0.1.0.2

Executables (1)

  • bin/slugger

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows