Documentation
¶
Index ¶
- func DefaultStopWords(lang string) map[string]struct{}
- func TransliterateBangla(input string, b *strings.Builder) string
- func TransliterateGeneric(input string, b *strings.Builder)
- func TransliterateRussian(input string, b *strings.Builder)
- func TransliterateUnidecode(input string, b *strings.Builder)
- type Cache
- type Config
- type Options
- func WithAbbreviation(from, to string) Options
- func WithLanguage(lang string) Options
- func WithMaxLength(max int) Options
- func WithPipeline(transformers ...Transformer) Options
- func WithRegexFilter(pattern, replace string) Options
- func WithStopWords(lang string) Options
- func WithSuffixStyle(style string) Options
- func WithUnidecode(enabled bool) Options
- func WithUseCache(use bool) Options
- func WithZeroAlloc(enabled bool) Options
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStopWords ¶
DefaultStopWords returns a basic stopwords map.
func TransliterateBangla ¶
TransliterateBangla converts Bengali text to Banglish.
func TransliterateGeneric ¶
transliterateGeneric handles basic Latin normalization.
func TransliterateRussian ¶
transliterateCyrillic handles Cyrillic script (Russian).
func TransliterateUnidecode ¶
transliterateUnidecode default (no dependency) version.
Types ¶
type Cache ¶
Cache is a simple in-memory store for slug uniqueness.
type Config ¶
type Config struct {
MaxLength int // Maximum allowed length of the final slug (e.g., 220 characters)
SuffixStyle string // Style of suffix: "numeric" (-2), "version" (-v2), "revision" (-rev2)
Language string // Language will hold the preferred Language to transliteration Default: english
RegexReplace string // Will hold the things that will be replaced
StopWords map[string]struct{} // All words that will be removed from the input if given
Abbreviations map[string]string // Abbreviations that will be removed from the input if given
UseCache bool // Flag to enable in-memory caching of slug lookups
ZeroAlloc bool // Controls zero-allocation mode
UseUnidecode bool // Optional unidecode fallback
Cache *Cache // In-memory cache struct
RegexFilter *regexp.Regexp // Regex pattern to replace certain characters from input if given
PipeLine []Transformer // Pipeline for step by step process
Builder strings.Builder // Buffer for zero-allocation processing
}
Config is the main struct for generating slugs.
func (*Config) EnsureUnique ¶
EnsureUnique ensures the slug is unique using the in-memory cache.
type Options ¶
type Options func(*Config)
Option defines a functional option for configuring Config.
func WithAbbreviation ¶
WithAbbreviation adds a custom abbreviation rule.
func WithLanguage ¶
WithLanguage sets the language for transliteration.
func WithMaxLength ¶
WithMaxLength sets the maximum length of the slug
func WithPipeline ¶
func WithPipeline(transformers ...Transformer) Options
WithPipeline sets custom transformations for the slug generation pipeline.
func WithRegexFilter ¶
WithRegexFilter sets a regex pattern to filter characters
func WithStopWords ¶
WithStopWords sets stopwords to remove from the slug
func WithSuffixStyle ¶
WithSuffixStyle sets the style for suffix generation ("numeric", "version", "revision")
func WithUnidecode ¶
WithUnidecode enables the unidecode fallback.
func WithUseCache ¶
WithUseCache enables or disables in-memory caching for uniqueness
func WithZeroAlloc ¶
WithZeroAlloc enables/disables zero-allocation mode.
type Transformer ¶
Transformer defines a function that transform a string in pipeline.
func RemoveDiacritics ¶
func RemoveDiacritics() Transformer
RemoveDiacritics removes diacritics using Unicode normalization.
func ReplaceSpaces ¶
func ReplaceSpaces(delimeter string) Transformer
ReplaceSpaces replaces spaces with dashes.
