FSlugify 1.2.1

dotnet add package FSlugify --version 1.2.1                
NuGet\Install-Package FSlugify -Version 1.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSlugify" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FSlugify --version 1.2.1                
#r "nuget: FSlugify, 1.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FSlugify as a Cake Addin
#addin nuget:?package=FSlugify&version=1.2.1

// Install FSlugify as a Cake Tool
#tool nuget:?package=FSlugify&version=1.2.1                

FSlugify

Build status NuGet

Simple and minimalistic slug generator library written entirely in F#.

It's easy to use and has no extra dependencies.

Add package

If you want to add this package to your project, execute the following command:

dotnet add package FSlugify --version 1.2.0

Build on your machine

If you want to build this library on your machine, execute the following commands:

git clone https://github.com/galassie/fslugify.git
cd fslugify
dotnet build

If you want to run the tests, execute the following command:

dotnet test

Build in Docker

Required:

  • Install Docker for your system

Build a Docker image called fslugify. This will work without any local .NET Core installation.

docker build -t fslugify .

Use the following to instantiate a Docker container from the fslugify image and run the tests inside:

docker run --rm fslugify dotnet test

Usage

You can see the some examples in the folder "samples" (both in C# and F#).

Here how it looks a simple F# program that uses this library:

open FSlugify.SlugGenerator

[<EntryPoint>]
let main argv =
    printfn "This is a series of examples on how to use the SlugGenerator!\n"

    slugify DefaultSlugGeneratorOptions "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" with default options: \"%s\"\n"

    slugify { DefaultSlugGeneratorOptions with Separator = '#' } "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" with custom separator: \"%s\"\n"
    
    slugify { DefaultSlugGeneratorOptions with Lowercase = false } "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" without lowercase: \"%s\"\n"
    
    let customMap = [("|", " or "); ("🤡", " clown ")]
    slugify { DefaultSlugGeneratorOptions with CustomMap = customMap } "Test | 🤡"
    |> printfn "Slug generated from \"Test | 🤡\" with custom map: \"%s\"\n"
    0

This program will output the following text:

This is a series of examples on how to use the SlugGenerator!

Slug generated from "Déjà Vu!" with default options: "deja_vu"

Slug generated from "Déjà Vu!" with custom separator: "deja#vu"

Slug generated from "Déjà Vu!" without lowercase: "Deja_Vu"

Slug generated from "Test | 🤡" with custom map: "test_or_clown"

Slug Custom Computation Expression

It is possible to use the custom Computation Expression in order to define your custom slugify function.

Here a simple example:

open FSlugify.Builder

[<EntryPoint>]
let main argv =
    printfn "This example shows how to use the custom Slug Computation Expression!\n"

    let customSlugify = slug {
            separator '@'
            lowercase false
            custom_map ("|", " or ")
            custom_map ("&", " and ")
            custom_map ("⏳", " hourglass ")
            custom_map ("🤡", " clown")
        }

    customSlugify "Test | Case"
    |> printfn "Slug generated from \"Test | Case\": \"%s\"\n"

    customSlugify " Test  &  ⏳ "
    |> printfn "Slug generated from \"  Test  &  ⏳  \": \"%s\"\n"

    customSlugify "HI 🤡!!!"
    |> printfn "Slug generated from \"HI 🤡!!!\": \"%s\"\n"
    0

This program will output the following text:

This example shows how to use the custom Slug Computation Expression!

Slug generated from "Test | Case": "Test@or@Case"

Slug generated from "  Test  &  ⏳  ": "Test@and@hourglass"

Slug generated from "HI 🤡!!!": "HI@clown"

FSlugify.Adapter

Although the library is usable as it is in a C# project (as it shown in the C# sample), for a better usability (both in syntax and usability) it's preferred to use the library FSlugify.Adapter.

Contributing

Code contributions are more than welcome! 😻

Please commit any pull requests against the master branch.
If you find any issue, please report it!

License

This project is licensed under The MIT License (MIT).

Author: Enrico Galassi

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FSlugify:

Package Downloads
FSlugify.Adapter

Ad Object-Oriented adapter to the functional FSlugify library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 579 11/24/2022
1.2.0 464 3/10/2022
1.1.0 1,046 2/10/2020
1.0.0 820 12/4/2019
1.0.0-rc1 371 11/23/2019
1.0.0-beta003 586 11/5/2019
1.0.0-beta002 423 11/4/2019
1.0.0-beta001 336 10/29/2019
1.0.0-alpha003 370 10/28/2019