package precis
import (
"unicode"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
var (
Nickname *Profile = nickname
UsernameCaseMapped *Profile = usernameCaseMap
UsernameCasePreserved *Profile = usernameNoCaseMap
OpaqueString *Profile = opaquestring
)
var (
nickname = &Profile {
options : getOpts (
AdditionalMapping (func () transform .Transformer {
return &nickAdditionalMapping {}
}),
IgnoreCase ,
Norm (norm .NFKC ),
DisallowEmpty ,
repeat ,
),
class : freeform ,
}
usernameCaseMap = &Profile {
options : getOpts (
FoldWidth ,
LowerCase (),
Norm (norm .NFC ),
BidiRule ,
),
class : identifier ,
}
usernameNoCaseMap = &Profile {
options : getOpts (
FoldWidth ,
Norm (norm .NFC ),
BidiRule ,
),
class : identifier ,
}
opaquestring = &Profile {
options : getOpts (
AdditionalMapping (func () transform .Transformer {
return mapSpaces
}),
Norm (norm .NFC ),
DisallowEmpty ,
),
class : freeform ,
}
)
var mapSpaces transform .Transformer = runes .Map (func (r rune ) rune {
if unicode .Is (unicode .Zs , r ) {
return ' '
}
return r
})
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .