Documentation ¶
Overview ¶
Package html contains HTML styling options.
Index ¶
- func Bytes(resolver func(id int) (tg.InputUserClass, error), b []byte) styling.StyledTextOption
- func Format(resolver func(id int) (tg.InputUserClass, error), format string, ...) styling.StyledTextOption
- func Reader(resolver func(id int) (tg.InputUserClass, error), r io.Reader) styling.StyledTextOption
- func String(resolver func(id int) (tg.InputUserClass, error), s string) styling.StyledTextOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
func Bytes(resolver func(id int) (tg.InputUserClass, error), b []byte) styling.StyledTextOption
Bytes reads HTML from given byte slice and returns styling option to build styled text block.
func Format ¶
func Format(resolver func(id int) (tg.InputUserClass, error), format string, args ...interface{}) styling.StyledTextOption
Format formats string using fmt, parses HTML from formatted string and returns styling option to build styled text block.
func Reader ¶
func Reader(resolver func(id int) (tg.InputUserClass, error), r io.Reader) styling.StyledTextOption
Reader reads HTML from given reader and returns styling option to build styled text block.
func String ¶
func String(resolver func(id int) (tg.InputUserClass, error), s string) styling.StyledTextOption
String reads HTML from given string and returns styling option to build styled text block.
Example ¶
package main import ( "context" "fmt" "os" "os/signal" "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/message" "github.com/gotd/td/telegram/message/html" "github.com/gotd/td/tg" ) func sendHTML(ctx context.Context) error { client, err := telegram.ClientFromEnvironment(telegram.Options{}) if err != nil { return err } // This example creates a styled message from BotAPI examples // and sends to your Saved Messages folder. // See https://core.telegram.org/bots/api#html-style. return client.Run(ctx, func(ctx context.Context) error { _, err := message.NewSender(tg.NewClient(client)). Self().StyledText(ctx, html.String(nil, `<b>bold</b>, <strong>bold</strong> <i>italic</i>, <em>italic</em> <u>underline</u>, <ins>underline</ins> <s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del> <b>bold <i>italic bold <s>italic bold strikethrough</s> <u>underline italic bold</u></i> bold</b> <a href="http://www.example.com/">inline URL</a> <a href="tg://user?id=123456789">inline mention of a user</a> <code>inline fixed-width code</code> <pre>pre-formatted fixed-width code block</pre> <pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>`)) return err }) } func main() { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() if err := sendHTML(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err) os.Exit(2) } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.