onehtml Go cookbook
HTML and selectors
Parse HTML and query CSS selectors in GoParse an HTML document in Go, select matching elements with a CSS selector, and read their text without launching a browser or running JavaScript.Extract links and link text from HTML in GoExtract each anchor’s href and link text from HTML in Go, including nested text, and resolve relative hrefs against a base URL when needed.
HTML parsing
Detect HTML character encoding in GoDetect an HTML page’s starting character encoding from its byte order mark, HTTP Content-Type header, or meta charset declaration.Parse an HTML fragment with element context in GoParse HTML as the contents of an element in Go. Use a tbody context to read table rows, or derive context from an existing node.
Computed CSS
Read registered CSS custom properties in GoRead the syntax, initial value, and inheritance flag of CSS @property rules in Go, then see which value a parent and child actually use.Find CSS declarations invalid at computed-value time in GoReport which CSS declarations win the cascade but fail after var() substitution, with the affected element, the original value, and the selector.Resolve CSS ch and ex units in GoSupply x-height and zero-glyph advance with onehtml-go’s WithFontMetrics, then read CSS ch and ex lengths in pixels without loading a browser.