A passive slugging module -- simple, transliteration-free slugs.




Build Status

A passive slugging module -- simple, transliteration-free slugs.

Given Elixir handles UTF-8 without issue, and browsers handle UTF-8 without issue both in content and in URIs, why should you fight your users' preferred input?

Transliteration is ridiculously difficult and expensive. The best we have are brute force libraries:

Here's an example: what would a typical transliteration of 消防署 be? Chances are it would be transformed to xiāofángshǔ. That's fine if you intended it to be Chinese, but totally incorrect if it was supposed to be Japanese (shōbōsho). Do all German speakers want ß to be cast to s or ss?

The gist of all of this is: take the path of least resistance and don't try to force everything to conform to ASCII.


SimpleSlug can be installed by adding simple_slug to your list of dependencies in mix.exs:

def deps do
    {:simple_slug, "~> 0.1.0"}


iex> SimpleSlug.slugify("Hello World")

iex> SimpleSlug.slugify("Hello World", joiner: "_")

iex> SimpleSlug.slugify("Hello World", lowercase?: false)

iex> SimpleSlug.slugify("Hello World", truncate: 5)

iex> SimpleSlug.slugify("Hello World", truncate: 6)

iex> SimpleSlug.slugify("Straßen von Berlin")

iex> SimpleSlug.slugify("東京キャブ乗り場2018年1月")