Documentation
¶
Overview ¶
Package equiv provides HTML/SEO/AI field comparison utilities for verifying huan output equivalence against Hugo.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeHTML ¶
NormalizeHTML returns a canonical form of the input HTML, suitable for byte-level comparison of pages that should render identically.
Normalizations applied:
- Implicit html/head/body wrappers injected by the parser are stripped, so fragment-in == fragment-out and full-document-in == full-document-in.
- Whitespace between tags is removed (<div>\n <p> → <div><p>)
- Self-closing tags are canonicalized (<br/> and <br /> → <br/>)
- Attributes are sorted by name with double-quoted values
- Boolean attributes are normalized
- HTML entities in text/attribute values are normalized to Go's html.EscapeString output (numeric character references for `"`, named for `& < > '`). This may differ from Hugo's named-entity usage — track and align if real data shows divergence in Phase 2b.
Types ¶
type AIFields ¶
type AIFields struct {
MainText string // innerText of <main> > <article> > <div class="main"> (first non-empty wins)
Outline []Heading // h1-h6 in document order
JSONLD []string // same content as SEOFields.JSONLD
Semantic map[string]bool // which semantic elements are present
}
AIFields is the set of HTML fields that affect LLM crawler friendliness.
type Report ¶
type Report struct {
Mode Mode
Identical int
Differing []string // relative paths (non-whitelisted)
Whitelisted []string // relative paths that matched the allowlist
MissingInA []string // files only in B
ExtraInA []string // files only in A
}
Report is the output of a single mode comparison over a pair of dirs.
func CompareDirs ¶
CompareDirs runs the given mode across two parallel directory trees. Files considered: .html / .htm / .xml. allowlist is a set of relative paths that are accepted as permanent differences (not counted as failures).
func (Report) FormatSummary ¶
FormatSummary returns a human-readable summary line.
type SEOFields ¶
type SEOFields struct {
Title string
Description string
OG map[string]string // property -> content
Twitter map[string]string // name (twitter:*) -> content
Canonical string
Robots string
Headings []Heading
JSONLD []string // normalized (re-marshaled) JSON strings
Links []Link // href + nofollow pairs
}
SEOFields is the set of HTML fields that affect SEO.
func ExtractSEO ¶
ExtractSEO parses the HTML and returns normalized SEO fields.