Documentation
¶
Index ¶
- func AddSecret(value, name string)
- func GetSecretIndexByValue(value string) int
- func IsSpecial(r rune) bool
- func RemoveSecretByName(name string)
- func RemoveSecretByValue(value string)
- func SecretValueExists(value string) bool
- type TextStyle
- type WMarkDown
- func GetBold(values ...any) WMarkDown
- func GetCodeBlock(values ...any) WMarkDown
- func GetCodeBlockLang(lang, text string) WMarkDown
- func GetEmpty() WMarkDown
- func GetHyperLink(text string, url string) WMarkDown
- func GetItalic(values ...any) WMarkDown
- func GetMono(values ...any) WMarkDown
- func GetNormal(values ...any) WMarkDown
- func GetSpoiler(values ...any) WMarkDown
- func GetStrike(values ...any) WMarkDown
- func GetStyled(text string, styles ...TextStyle) WMarkDown
- func GetUnderline(values ...any) WMarkDown
- func GetUserMention(text string, userID int64) WMarkDown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSecret ¶ added in v1.0.14
func AddSecret(value, name string)
AddSecret adds a new secret variable to the mdparser *globally*. from now on, the library itself will automatically censor all of the "value"s with their name. an example of usage would be:
mdparser.AddSecret(bot.Token, "$TOKEN")
func GetSecretIndexByValue ¶ added in v1.0.14
func RemoveSecretByName ¶ added in v1.0.14
func RemoveSecretByName(name string)
func RemoveSecretByValue ¶ added in v1.0.14
func RemoveSecretByValue(value string)
func SecretValueExists ¶ added in v1.0.14
Types ¶
type TextStyle ¶ added in v1.1.4
type TextStyle uint8
TextStyle identifies a nestable Telegram text style.
const ( // StyleBold applies bold formatting. StyleBold TextStyle = 1 << iota // StyleItalic applies italic formatting. StyleItalic // StyleUnderline applies underline formatting. StyleUnderline // StyleStrike applies strike-through formatting. StyleStrike // StyleSpoiler applies spoiler formatting. StyleSpoiler )
type WMarkDown ¶
type WMarkDown interface {
// Append appends another markdown value to the current markdown.
Append(md WMarkDown) WMarkDown
// Clone returns a copy of the current markdown value.
Clone() WMarkDown
// ReplaceMd replaces all matching markdown fragments with another markdown value.
ReplaceMd(md1, md2 WMarkDown) WMarkDown
// ReplaceMdN replaces up to n matching markdown fragments with another markdown value.
ReplaceMdN(md1, md2 WMarkDown, n int) WMarkDown
// ToString returns the final markdown string.
ToString() string
// ReplaceToNew replaces all matching plain-text fragments with escaped plain-text replacements.
ReplaceToNew(text1, text2 string) WMarkDown
// ReplaceToNewN replaces up to n matching plain-text fragments with escaped plain-text replacements.
ReplaceToNewN(text1, text2 string, n int) WMarkDown
// Normal appends plain escaped text built from mixed values.
Normal(values ...any) WMarkDown
// Bold appends bold markdown text built from mixed values.
Bold(values ...any) WMarkDown
// Italic appends italic markdown text built from mixed values.
Italic(values ...any) WMarkDown
// Mono appends inline code wrapped in single backticks built from mixed values.
Mono(values ...any) WMarkDown
// Styled appends text wrapped in one or more nestable text styles.
Styled(text string, styles ...TextStyle) WMarkDown
// CodeBlock appends a fenced code block built from mixed values.
CodeBlock(values ...any) WMarkDown
// CodeBlockLang appends a fenced code block with a language hint.
CodeBlockLang(lang, text string) WMarkDown
// HyperLink appends a markdown hyperlink.
HyperLink(text, url string) WMarkDown
// Link appends a markdown hyperlink.
Link(text, url string) WMarkDown
// Mention appends a Telegram user mention.
Mention(text string, id int64) WMarkDown
// UserMention appends a Telegram user mention.
UserMention(text string, id int64) WMarkDown
// Spoiler appends spoiler markdown built from mixed values.
Spoiler(values ...any) WMarkDown
// Strike appends strike-through markdown built from mixed values.
Strike(values ...any) WMarkDown
// Underline appends underline markdown built from mixed values.
Underline(values ...any) WMarkDown
// El appends a newline.
El() WMarkDown
// Space appends a space.
Space() WMarkDown
// Tab appends a tab.
Tab() WMarkDown
// Replace replaces all matching escaped plain-text fragments in the current value.
Replace(text1, text2 string) WMarkDown
// ReplaceN replaces up to n matching escaped plain-text fragments in the current value.
ReplaceN(text1, text2 string, n int) WMarkDown
}
WMarkDown is the mutable markdown builder exposed by this package. Every instance method mutates the current value unless you explicitly call Clone first.
func GetCodeBlock ¶ added in v1.1.4
func GetCodeBlockLang ¶ added in v1.1.4
func GetHyperLink ¶
func GetSpoiler ¶ added in v1.0.8
func GetUnderline ¶ added in v1.0.8
func GetUserMention ¶
GetUserMention will give you a mentioning style username with the specified text. WARNING: you don't need to repair text before sending it as first arg, this function will check it itself.
Click to show internal directories.
Click to hide internal directories.