Documentation
¶
Index ¶
- Variables
- func EscapeMarkdown(r []rune, toEscape []rune) string
- func EscapeMarkdownV2(r []rune) string
- func IsEscaped(input []rune, pos int) bool
- func MD2HTML(input string) string
- func MD2HTMLV2(in string) string
- func Reverse(s string, buttons []Button) string
- func ReverseV2(in string, bs []ButtonV2) (string, error)
- func StripHTML(s string) string
- func StripHTMLV2(s string) string
- func StripMD(s string) string
- func StripMDV2(s string) string
- type Button
- type ButtonV2
- type Converter
- type ConverterV2
- func (cv ConverterV2) ButtonToMarkdown(btn ButtonV2) (string, error)
- func (cv ConverterV2) MD2HTML(in string) string
- func (cv ConverterV2) MD2HTMLButtons(in string) (string, []ButtonV2)
- func (cv ConverterV2) Reverse(in string, bs []ButtonV2) (string, error)
- func (cv ConverterV2) StripHTMLV2(s string) string
- func (cv ConverterV2) StripMDV2(s string) string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoButtonContent = errors.New("missing button name or contents") ErrInvalidButtonStyle = errors.New("invalid button style") )
Functions ¶
func EscapeMarkdown ¶
func EscapeMarkdownV2 ¶
func StripHTMLV2 ¶
Types ¶
type Button ¶
func MD2HTMLButtons ¶
type ButtonV2 ¶
type ButtonV2 struct {
// Name of the button, defined by the user inside the []
Name string
// The type of the button - as determined by the "prefixes" in ConverterV2
Type string
// The content of the button; a url, text, etc.
Content string
// Whether the button should be on the same line as the previous one.
SameLine bool
// According to telegram, one of: "danger" (red), "success" (green), or "primary" (blue).
// https://core.telegram.org/bots/api#keyboardbutton
Style string
}
ButtonV2 identifies a button. The markdown syntax for a button is as such (where <> represents fields) [<name>](<prefix>:<content>) [<name>](<prefix>:<content>:<sameline>) [<name>](<prefix>#<style>:<content>) [<name>](<prefix>#<style>:<content>:<sameline>)
func MD2HTMLButtonsV2 ¶
type Converter ¶
func (*Converter) MD2HTMLButtons ¶
type ConverterV2 ¶
type ConverterV2 struct {
// Prefixes determines how to map button types to button prefixes.
// Eg; "url": "buttonurl" creates a URL button when the prefix is "buttonurl"
Prefixes map[string]string
// Styles determines how to map style names to the relevant telegram value.
// Eg: "primary": "primary" just enabled "primary" style.
// Eg: "green": "success" would allow users to use "green" as an alias for "success"
Styles map[string]string
SameLineSuffix string
}
func (ConverterV2) ButtonToMarkdown ¶
func (cv ConverterV2) ButtonToMarkdown(btn ButtonV2) (string, error)
func (ConverterV2) MD2HTML ¶
func (cv ConverterV2) MD2HTML(in string) string
func (ConverterV2) MD2HTMLButtons ¶
func (cv ConverterV2) MD2HTMLButtons(in string) (string, []ButtonV2)
func (ConverterV2) Reverse ¶
func (cv ConverterV2) Reverse(in string, bs []ButtonV2) (string, error)
func (ConverterV2) StripHTMLV2 ¶
func (cv ConverterV2) StripHTMLV2(s string) string
func (ConverterV2) StripMDV2 ¶
func (cv ConverterV2) StripMDV2(s string) string
Click to show internal directories.
Click to hide internal directories.