Skip to content

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

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

vforgione/simple_slug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleSlug

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.

Installation

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

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

Examples

iex> SimpleSlug.slugify("Hello World")
"hello-world"

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

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

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

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

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

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

About

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

Resources

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages