Skip to content

PhaseSoftware/slug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slug

A small Go package that converts strings to a "slugified" version. The slugified version refers here to a string that should still represent the original meaning, but remove most special characters. No consideration was given to performance, this is mostly to convert file names to ones more easily parseable/pipeable.

go get -u github.com/phasesoftware/slug@v1.1.0

Usage

import "github.com/phasesoftware/slug"

slug.Ify("Schwiizerdütsch & svensk omljud ä ö å behandling")
// "Schwiizerdutsch-and-svensk-omljud-a-o-a-behandling"

slug.German.Ify("Schwiizerdütsch & svensk omljud ä ö å behandling")
// "Schwiizerduetsch-and-svensk-omljud-ae-oe-a-behandling"

Command line utility

The included slugify command line tool treats each input argument as a file system path and attempts to rename it to a slugified version.

Install

go install -v github.com/phasesoftware/slug/cmd/slugify@latest

Usage examples:

slugify "path/to/file"
slugify -de "path/to/german/file" # umlauts as digraphs, e.g. ü→ue
slugify path/with/wildcard*
ls *.mp4 | xargs -d '\n' slugify # GNU xargs
ls *.mp4 | tr \\n \\0 | xargs -0 slugify # macOS

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages