slug/doc.go

44 lines
1.1 KiB
Go
Raw Normal View History

2013-03-13 15:14:21 +01:00
// Copyright 2013 by Dobrosław Żybort. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/*
2013-03-13 15:17:44 +01:00
Package slug generate slug from unicode string, URL-friendly slugify with
2013-03-13 15:14:21 +01:00
multiple languages support.
Example:
package main
import(
"bitbucket.org/gosimple/slug"
2013-03-13 15:15:59 +01:00
"fmt"
2013-03-13 15:14:21 +01:00
)
2013-05-10 15:05:15 +02:00
func main () {
text := slug.Make("Hellö Wörld хелло ворлд")
fmt.Println(text) // Will print hello-world-khello-vorld
2013-03-13 15:14:21 +01:00
2013-05-10 15:05:15 +02:00
someText := slug.Make("影師")
fmt.Println(someText) // Will print: ying-shi
2013-03-13 15:14:21 +01:00
2013-05-10 15:05:15 +02:00
enText := slug.MakeLang("This & that", "en")
fmt.Println(enText) // Will print 'this-and-that'
2013-03-13 15:14:21 +01:00
2013-05-10 15:05:15 +02:00
deText := slug.MakeLang("Diese & Dass", "de")
fmt.Println(deText) // Will print 'diese-und-dass'
2013-05-10 17:51:12 +02:00
slug.CustomSub = map[string]string{
"water": "sand",
}
textSub := slug.Make("water is hot")
fmt.Println(textSub) // Will print 'sand-is-hot'
2013-05-10 15:05:15 +02:00
}
2013-03-13 15:14:21 +01:00
Requests or bugs?
https://bitbucket.org/gosimple/slug/issues
*/
package slug