package tgfmt import ( "strconv" ) // HTML is an escaped Telegram HTML fragment. // // Methods on HTML compose formatting without escaping the fragment again. type HTML string // EscapeHTML escapes special characters for Telegram HTML parse mode. func EscapeHTML(s string) HTML { return HTML(escapeHTML(s)) } // Bold returns h wrapped as bold Telegram HTML text. func (h HTML) Bold() HTML { return "" + h + "" } // Italic returns h wrapped as italic Telegram HTML text. func (h HTML) Italic() HTML { return "" + h + "" } // Underline returns h wrapped as underlined Telegram HTML text. func (h HTML) Underline() HTML { return "" + h + "" } // Strikethrough returns h wrapped as strikethrough Telegram HTML text. func (h HTML) Strikethrough() HTML { return "" + h + "" } // Spoiler returns h wrapped as spoiler Telegram HTML text. func (h HTML) Spoiler() HTML { return "" + h + "" } // Link returns h as a Telegram HTML text link. func (h HTML) Link(url string) HTML { return `` + h + "" } // Mention returns h as a Telegram HTML user mention. func (h HTML) Mention(userID int64) HTML { return `` + h + "" } // Emoji returns h as a Telegram HTML custom emoji. func (h HTML) Emoji(emojiID string) HTML { return `` + h + "" } // Time returns h as a Telegram HTML localized timestamp. func (h HTML) Time(unix int64) HTML { return `` + h + "" } // TimeFormat returns h as a Telegram HTML localized timestamp with format. func (h HTML) TimeFormat(unix int64, format string) HTML { return `` + h + "" } // InlineCode returns h wrapped as inline code Telegram HTML text. func (h HTML) InlineCode() HTML { return "" + h + "" } // BlockCode returns h wrapped as a Telegram HTML code block. func (h HTML) BlockCode() HTML { return "
" + h + "
" } // BlockCodeLanguage returns h wrapped as a Telegram HTML code block with language. func (h HTML) BlockCodeLanguage(lang string) HTML { return `
` + h + "
" } // Quote returns h as a Telegram HTML blockquote. func (h HTML) Quote() HTML { return "
" + h + "
" } // QuoteExpandable returns h as a Telegram HTML expandable blockquote. func (h HTML) QuoteExpandable() HTML { return "
" + h + "
" } func escapeHTMLAttr(s string) HTML { return HTML(escapeHTML(s)) }