slugify

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2016 License: MIT Imports: 4 Imported by: 36

README

go-slugify

Build Status Coverage Status Go Report Card GoDoc

Make Pretty Slug.

Installation

go get -u github.com/mozillazg/go-slugify

Install CLI tool:

go get -u github.com/mozillazg/go-slugify/slugify
$ slugify "北京kožušček,abc"
bei-jing-kozuscek-abc

Documentation

API documentation can be found here: https://godoc.org/github.com/mozillazg/go-slugify

Usage

package main

import (
	"fmt"
	"github.com/mozillazg/go-slugify"
)

func main() {
	s := "北京kožušček,abc"
	fmt.Println(slugify.Slugify(s))
	// Output: bei-jing-kozuscek-abc
}

Documentation

Overview

Package slugify implements Make Pretty Slug

s := "北京kožušček,abc"
fmt.Println(slugify.Slugify(s))
// Output: bei-jing-kozuscek-abc

Index

Examples

Constants

This section is empty.

Variables

View Source
var ReDupSeparatorChar = regexp.MustCompile(fmt.Sprintf("%s{2,}", SeparatorForRe))

ReDupSeparatorChar match duplicate separator string

View Source
var ReInValidChar = regexp.MustCompile(fmt.Sprintf("[^%sa-zA-Z0-9]", SeparatorForRe))

ReInValidChar match invalid slug string

View Source
var Separator = "-"

Separator separator between words

View Source
var SeparatorForRe = regexp.QuoteMeta(Separator)

SeparatorForRe for regexp

Functions

func Slugify

func Slugify(s string) string

Slugify implements make a pretty slug from the given text. e.g. Slugify("kožušček hello world") => "kozuscek-hello-world"

Example
s := "Nín hǎo. Wǒ shì zhōng guó rén This is a test ---"
fmt.Println(slugify.Slugify(s))
Output:

nin-hao-wo-shi-zhong-guo-ren-this-is-a-test

func Version

func Version() string

Version return version

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL