tools

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tools provides various methods for various things

Index

Constants

This section is empty.

Variables

View Source
var (

	// TagsTitleCase enforces TitleCase on all tags
	TagsTitleCase bool
)

Functions

func ArgsParser

func ArgsParser(s string) []string

ArgsParser will split a string by new words and quotes phrases

func CleanTag

func CleanTag(s string) string

CleanTag returns a clean tag, trimming whitespace and replacing invalid characters

func CreateSnippet added in v1.9.5

func CreateSnippet(text, html string) string

CreateSnippet returns a message snippet. It will use the HTML version (if it exists) otherwise the text version.

func GetHTMLAttributeVal

func GetHTMLAttributeVal(e *html.Node, key string) (string, error)

GetHTMLAttributeVal returns the value of an HTML Attribute, else an error. Returns a blank value if the attribute is set but empty.

func InArray added in v1.18.0

func InArray(k string, arr []string) bool

InArray tests if a string is within an array. It is not case sensitive.

func ListUnsubscribeParser added in v1.13.0

func ListUnsubscribeParser(v string) ([]string, error)

ListUnsubscribeParser will attempt to parse a `List-Unsubscribe` header and return a slide of addresses (mail & URLs)

func Normalize added in v1.18.7

func Normalize(s string) string

Normalize will remove any extra spaces, remove newlines, and trim leading and trailing spaces

func Plural added in v1.18.0

func Plural(total int, singular, plural string) string

Plural returns a singular or plural of a word together with the total

func RemoveMessageHeaders

func RemoveMessageHeaders(msg []byte, headers []string) ([]byte, error)

RemoveMessageHeaders scans a message for headers, if found them removes them. It will only remove a single instance of any given message header.

func SetTagCasing added in v1.18.0

func SetTagCasing(s []string) []string

SetTagCasing returns the slice of tags, title-casing if set

func UpdateMessageHeader added in v1.9.9

func UpdateMessageHeader(msg []byte, header, value string) ([]byte, error)

UpdateMessageHeader scans a message for a header and updates its value if found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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