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
}
Expand ▾ Collapse ▴

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
              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.

                Source Files

                Directories

                Path Synopsis