Giter VIP home page Giter VIP logo

go-texttools's Introduction

go-texttools

A collection of tools for manipulating texts in Go

Shorten tries to create the most sensible (to a human) shortened text.
If possible, it will try to cut at a non-word char.
It will strip newlines and carriage returns.

Shorten(str string, length int, appendStr string) (shorter string)

SpecialCharsToStandard replaces all kinds of non-ascii chars with transliterations.

SpecialCharsToStandard(str string) string

Slug will convert a string to a slug.
It will also do transliteration of non-ascii chars.

Slug(str string) string

UnCase takes a string in any "case" (kebab-case, snake_case, etc.) and creates a "normal" string.
E.g. my-slug-string -> "My slug string"

UnCase(str string) string

SnakeCase will convert a string to snake_case.

SnakeCase(str string) string

KebabCase will convert a string to kebab-case.

KebabCase(str string) string

CamelCase will convert a string to camelCase.

CamelCase(str string) string

PascalCase will convert a string to PascalCase.
This is the same as camelCase, but with the first letter capitalized.

PascalCase(str string) string

StringInSlice will check if a string is in a slice and return true if it is.

StringInSlice(searchStr string, strs []string) bool

HTMLToText converts HTML to standard text.

HTMLToText(html string) (text string)

TextSanitizer converts HTML to standard text, but also replaces some special chars and escapings.

SanitizeText(txt string) (newTxt string)

CP1258ToUTF8 converts a CP1258 byte array to a UTF-8 string.

CP1258ToUTF8(txt []byte) (utf8Txt string)

RandomString creates a secure pseudorandom string using the crypto rand package.

RandomString(n int) (str string)

go-texttools's People

Contributors

morphar avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.