html

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractMeta

func ExtractMeta(doc *Document) map[string]string

ExtractMeta collects <meta> tags into a map.

Keys come from the "name" or "property" attribute. The "content" attribute is used as the value. If both name and property are present, property takes precedence.

func ExtractTitle

func ExtractTitle(doc *Document) string

ExtractTitle returns the document <title> text, if any.

Types

type Document

type Document struct {
	Root *xhtml.Node
}

Document represents a parsed HTML document.

Root is the root node returned by the underlying HTML parser.

func ParseDocument

func ParseDocument(data []byte) (*Document, error)

ParseDocument parses raw HTML bytes into a Document.

It uses golang.org/x/net/html for robust HTML5 parsing.

type Heading

type Heading struct {
	Level int
	Text  string
}

Heading represents a heading element (h1–h6).

func ExtractHeadings

func ExtractHeadings(doc *Document) []Heading

ExtractHeadings extracts all headings (h1–h6) in document order.

type Link struct {
	Href string
	Text string
	Rel  string
}

Link represents a hyperlink in the document.

func ExtractLinks(doc *Document) []Link

ExtractLinks returns all <a> elements as Link values.

type Meta

type Meta struct {
	Name  string
	Value string
}

Meta represents a simple key/value metadata entry.

type Paragraph

type Paragraph struct {
	Text string
}

Paragraph represents a paragraph of text.

func ExtractParagraphs

func ExtractParagraphs(doc *Document) []Paragraph

ExtractParagraphs extracts <p> elements as Paragraph values.

Jump to

Keyboard shortcuts

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