pressly/node-slug

Name: node-slug

Owner: Pressly Inc.

Description: slugifies even utf-8 chars!

Forked from: dodo/node-slug

Created: 2017-04-13 19:52:08.0

Updated: 2017-04-13 19:52:10.0

Pushed: 2017-04-13 20:53:48.0

Homepage:

Size: 80

Language: CoffeeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This is a Fork of node-slug with the unicode support removed - no longer have to handle issues related t unicode/category/So

slug

slugifies every string, even when it contains unicode!

Make strings url-safe.

install slug

r install slug
example
slug = require('slug')
print = console.log.bind(console, '>')

t(slug('i ? unicode'))
 i-love-unicode

t(slug('unicode ? is ?')) // yes!
 unicode-love-is-radioactive

t(slug('i ? unicode', '_')) // If you prefer something else then `-` as seperator
 i_love_unicode

.charmap['?'] = 'freaking love' // change default charmap or use option {charmap:{?}} as 2. argument
t(slug('I ? UNICODE'))
 I-freaking-love-UNICODE

t(slug('?-Number', {lower: true})) // If you prefer lower case
 telephone-number

t(slug('i <3 unicode'))
 i-love-unicode
options
ptions is either object or replacement (sets options.replacement)
('string', [{options} || 'replacement']);
avascript
.defaults.mode ='pretty';
.defaults.modes['rfc3986'] = {
replacement: '-',      // replace spaces with replacement
symbols: true,         // replace unicode symbols or not
remove: null,          // (optional) regex to remove characters
lower: true,           // result in lower case
charmap: slug.charmap, // replace special characters
multicharmap: slug.multicharmap // replace multi-characters

.defaults.modes['pretty'] = {
replacement: '-',
symbols: true,
remove: /[.]/g,
lower: false,
charmap: slug.charmap,
multicharmap: slug.multicharmap

browser

When using browserify you might want to remove the symbols table from your bundle by using --ignore similar to this:

nerates a standalone slug browser bundle:
serify slug.js --ignore unicode/category/So -s slug > slug-browser.js

Build Status

Bitdeli Badge


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.