htmlutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractImageURLs

func ExtractImageURLs(s string) []string

ExtractImageURLs finds image URLs from <img src> tags and <figure data-trix-attachment> elements.

func MessageSourceText added in v0.2.0

func MessageSourceText(s string) string

MessageSourceText returns the source-backed text carried by HTML message content.

func PrependText

func PrependText(content, note string) string

PrependText adds a plain-text note before existing HTML content.

func ToText

func ToText(s string) string

ToText converts HTML content to plain text, preserving basic structure.

Types

type Attachment

type Attachment struct {
	URL         string
	Filename    string
	ContentType string
	ByteSize    *int64
	SGID        string
}

Attachment describes a downloadable file embedded in rich-text content.

func ExtractAttachments

func ExtractAttachments(s string) []Attachment

ExtractAttachments returns downloadable files in their document order.

type Markdown added in v0.2.0

type Markdown struct {
	// contains filtered or unexported fields
}

Markdown is Markdown that ToMarkdown produced: every context serialized on its own terms, and no control character left in it other than the newlines and tabs that Markdown itself is written with — a fence keeps its tabs, and a sink that shows it sanitizes with the same two allowed. It is the only kind of Markdown markdown.Render accepts, and nothing but ToMarkdown can make one — the field is unexported and there is no constructor — so a body from anywhere else cannot reach a terminal renderer by being a string that happens to look like Markdown. It marshals to JSON as the string it holds, which is what --json carries.

func ToMarkdown added in v0.2.0

func ToMarkdown(s string) Markdown

ToMarkdown converts HTML content to Markdown. Unlike ToText it keeps what a flattened email throws away: link URLs, emphasis, headings, list nesting, quotes, code blocks and tables. What it returns is the only Markdown markdown.Render accepts; see the Markdown type.

func (Markdown) IsEmpty added in v0.2.0

func (m Markdown) IsEmpty() bool

IsEmpty reports Markdown with nothing in it; IsZero is the same, for `omitzero`.

func (Markdown) IsZero added in v0.2.0

func (m Markdown) IsZero() bool

func (Markdown) MarshalText added in v0.2.0

func (m Markdown) MarshalText() ([]byte, error)

MarshalText writes the Markdown as a JSON string.

func (Markdown) String added in v0.2.0

func (m Markdown) String() string

String is the Markdown text, for a sink that writes Markdown rather than rendering it.

Jump to

Keyboard shortcuts

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