v1.6.0 Latest Latest

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

Go to latest
Published: Sep 14, 2023 License: MPL-2.0 Imports: 11 Imported by: 3




This section is empty.


This section is empty.


func ApplyBasicAccessibleMarkdown added in v1.4.1

func ApplyBasicAccessibleMarkdown(data []byte) string

ApplyBasicAccessibleMarkdown applies Markdown to the given data, rendering basic text formatting and preserving hard line breaks in HTML. It is meant for formatting text in small, multi-line UI elements, like user profile biographies.

func ApplyBasicMarkdown

func ApplyBasicMarkdown(data []byte) string

func ApplyMarkdown

func ApplyMarkdown(data []byte) string

func ExtractTitle

func ExtractTitle(content string) (title string, body string)

ExtractTitle takes the given raw post text and returns a title, if explicitly provided, and a body.

func FriendlyPostTitle added in v1.4.0

func FriendlyPostTitle(content, friendlyId string) string

func GetSlug added in v1.5.0

func GetSlug(title, lang string) string

func GetSlugFromPost added in v1.5.0

func GetSlugFromPost(title, body, lang string) string

func PostDescription added in v1.4.0

func PostDescription(content, title, friendlyId string) string

PostDescription generates a description based on the given post content, title, and post ID. This doesn't consider a V2 post field, `title` when choosing what to generate. In case a post has a title, this function will fail, and logic should instead be implemented to skip this when there's no title, like so:

var desc string
if title == "" {
    desc = PostDescription(content, title, friendlyId)
} else {
    desc = ShortPostDescription(content)

func PostLede added in v1.4.0

func PostLede(t string, includePunc bool) string

PostLede attempts to extract the first thought of the given post, generally contained within the first line or sentence of text.

func PostTitle added in v1.5.0

func PostTitle(content, friendlyId string) string

func ShortPostDescription added in v1.4.0

func ShortPostDescription(content string) string

func StripHTMLWithoutEscaping added in v1.4.0

func StripHTMLWithoutEscaping(content string) string

StripHTMLWithoutEscaping strips HTML tags with bluemonday's StrictPolicy, then unescapes the HTML entities added in by sanitizing the content.

func TruncToWord added in v1.4.0

func TruncToWord(s string, l int) (string, bool)

TruncToWord truncates the given text to the provided limit.


This section is empty.

Jump to

Keyboard shortcuts

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