strcase

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel added in v0.5.0

func Camel(s string) string

func Constant added in v0.5.0

func Constant(s string) string

func Dash added in v0.5.0

func Dash(s string) string

func Dot added in v0.5.0

func Dot(s string) string

func Pascal added in v0.5.0

func Pascal(s string) string

func Simple added in v0.5.0

func Simple(s string) string

func Snake added in v0.5.0

func Snake(s string) string

Types

type CaseConverter added in v0.6.0

type CaseConverter interface {
	Convert(string) string
}

A CaseConverter converts a string to a specific case.

type CaseOptFunc added in v0.6.0

type CaseOptFunc func(opts *CaseOpts)

CaseOptFunc is a function that modifies a CaseConverter.

func UsingIndicator

func UsingIndicator(indicator IndicatorFunc) CaseOptFunc

UsingIndicator sets the indicator for the CaseConverter.

func UsingPrefix added in v0.9.0

func UsingPrefix(prefix string) CaseOptFunc

UsingPrefix sets the prefix for the CaseConverter.

func UsingVocab

func UsingVocab(vocab []string) CaseOptFunc

UsingVocab sets the vocab for the CaseConverter.

type CaseOpts added in v0.6.0

type CaseOpts struct {
	// contains filtered or unexported fields
}

CaseOpts is a struct that holds the options for a CaseConverter.

type IgnoreFunc

type IgnoreFunc func(word string, tags []tag.Token, idx int, firstOrLast bool) bool

An IgnoreFunc is a TitleConverter callback that decides whether or not the the string word should be capitalized. firstOrLast indicates whether or not word is the first or last word in the given string.

var (
	APStyle      IgnoreFunc = optionsAP
	ChicagoStyle IgnoreFunc = optionsChicago
)

type IndicatorFunc

type IndicatorFunc func(word string, idx int) bool

An IndicatorFunc is a SentenceConverter callback that decides whether or not the string word should be capitalized.

type SentenceConverter

type SentenceConverter struct {
	CaseOpts
}

A SentenceConverter converts a string to sentence case.

func NewSentenceConverter

func NewSentenceConverter(opts ...CaseOptFunc) *SentenceConverter

NewSentenceConverter returns a new SentenceConverter.

func (*SentenceConverter) Convert added in v0.6.0

func (sc *SentenceConverter) Convert(s string) string

Convert returns a copy of the string s in sentence case format.

type TitleConverter

type TitleConverter struct {
	CaseOpts
	// contains filtered or unexported fields
}

A TitleConverter converts a string to title case according to its style.

func NewTitleConverter

func NewTitleConverter(style IgnoreFunc, opts ...CaseOptFunc) *TitleConverter

NewTitleConverter returns a new TitleConverter set to enforce the specified style.

func (*TitleConverter) Convert added in v0.6.0

func (tc *TitleConverter) Convert(s string) string

Convert returns a copy of the string s in title case format.

Jump to

Keyboard shortcuts

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