let's see how we go...
This commit is contained in:
22
generator/src/Slug.hs
Normal file
22
generator/src/Slug.hs
Normal file
@@ -0,0 +1,22 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Slug
|
||||
( toSlug,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Char (isAlphaNum)
|
||||
import qualified Data.Text as T
|
||||
|
||||
keepAlphaNum :: Char -> Char
|
||||
keepAlphaNum x
|
||||
| isAlphaNum x = x
|
||||
| otherwise = ' '
|
||||
|
||||
clean :: T.Text -> T.Text
|
||||
clean =
|
||||
T.map keepAlphaNum . T.replace "'" "" . T.replace "&" "and"
|
||||
|
||||
toSlug :: T.Text -> T.Text
|
||||
toSlug =
|
||||
T.intercalate (T.singleton '-') . T.words . T.toLower . clean
|
||||
Reference in New Issue
Block a user