sanitize: github.com/kennygrant/sanitize Index | Files

package sanitize

import "github.com/kennygrant/sanitize"

Package sanitize provides functions for sanitizing text.

Index

Package Files

sanitize.go

func Accents Uses

func Accents(s string) string

Accents replaces a set of accented characters with ascii equivalents.

func BaseName Uses

func BaseName(s string) string

BaseName makes a string safe to use in a file name, producing a sanitized basename replacing . or / with -. No attempt is made to normalise a path or normalise case.

func HTML Uses

func HTML(s string) (output string)

HTML strips html tags, replace common entities, and escapes <>&;'" in the result. Note the returned text may contain entities as it is escaped by HTMLEscapeString, and most entities are not translated.

func HTMLAllowing Uses

func HTMLAllowing(s string, args ...[]string) (string, error)

HTMLAllowing sanitizes html, allowing some tags. Arrays of allowed tags and allowed attributes may optionally be passed as the second and third arguments.

func Name Uses

func Name(s string) string

Name makes a string safe to use in a file name by first finding the path basename, then replacing non-ascii characters.

func Path Uses

func Path(s string) string

Path makes a string safe to use as a URL path, removing accents and replacing separators with -. The path may still start at / and is not intended for use as a file system path without prefix.

Package sanitize imports 8 packages (graph) and is imported by 184 packages. Updated 2021-01-19. Refresh now. Tools for package owners.