html

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLinkAllocSize  = 200
	DefaultMaxMessageSize = telegram.MaxMessageSize - DefaultLinkAllocSize
	DefaultMaxCaptionSize = telegram.MaxCaptionSize - DefaultLinkAllocSize
)
View Source
var (
	Bold   = Tag{Open: "<b>", Close: "</b>"}
	Italic = Tag{Open: "<i>", Close: "</i>"}
	Code   = Tag{Open: "<code>", Close: "</code>"}
	Pre    = Tag{Open: "<pre>", Close: "</pre>"}
)
View Source
var DefaultTagConverter = PlainTagConverter{
	"strong": Bold,
	"b":      Bold,
	"italic": Italic,
	"em":     Italic,
	"i":      Italic,
	"code":   Code,
	"pre":    Pre,
}

Functions

func Anchor

func Anchor(text, href string) string

func Get

func Get(attrs []html.Attribute, key string) string

Types

type AnchorFormat

type AnchorFormat interface {
	Format(text string, attrs []html.Attribute) string
}
var DefaultAnchorFormat AnchorFormat = defaultAnchorFormat{}

type Output

type Output interface {
	IsOverflown() bool
	UpdatePrefix(update func(prefix string) string)
	UpdateSuffix(update func(suffix string) string)
	Write(text string)
	WriteBreakable(ctx context.Context, text string) error
	WriteUnbreakable(ctx context.Context, text string) error
	AddMedia(ctx context.Context, ref syncf.Ref[*receiver.Media], anchor string, collapsible bool) error
	BreakPage(ctx context.Context) error
	Flush(ctx context.Context) error
	PageCapacity(ctx context.Context) int
}

type PlainTagConverter

type PlainTagConverter map[string]Tag

func (PlainTagConverter) Get

func (c PlainTagConverter) Get(name string, _ []html.Attribute) (Tag, bool)

type Tag

type Tag struct {
	Open, Close string
	// contains filtered or unexported fields
}

type TagConverter

type TagConverter interface {
	Get(tag string, attrs []html.Attribute) (Tag, bool)
}

type Writer

type Writer struct {
	Out     Output
	Tags    TagConverter
	Anchors AnchorFormat
	// contains filtered or unexported fields
}

func (*Writer) Bold

func (w *Writer) Bold(text string, args ...interface{}) *Writer

func (*Writer) Code

func (w *Writer) Code(text string, args ...interface{}) *Writer

func (*Writer) Context

func (w *Writer) Context() context.Context

func (*Writer) EndTag

func (w *Writer) EndTag() *Writer

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) Italic

func (w *Writer) Italic(text string, args ...interface{}) *Writer
func (w *Writer) Link(text, href string) *Writer

func (*Writer) Markup

func (w *Writer) Markup(reader io.Reader) *Writer

func (*Writer) MarkupString

func (w *Writer) MarkupString(markup string) *Writer

func (*Writer) Media

func (w *Writer) Media(url string, ref syncf.Ref[*receiver.Media], collapsible bool, anchored bool) *Writer

func (*Writer) Pre

func (w *Writer) Pre(text string, args ...interface{}) *Writer

func (*Writer) StartTag

func (w *Writer) StartTag(name string, attrs []html.Attribute) *Writer

func (*Writer) Text

func (w *Writer) Text(text string, args ...interface{}) *Writer

func (*Writer) WithContext added in v0.10.9

func (w *Writer) WithContext(ctx context.Context) *Writer

Jump to

Keyboard shortcuts

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