Documentation
¶
Overview ¶
Package svgcontent extracts the *semantic* (visible / structural) content of a rendered metrics SVG so tests can assert on what a viewer actually sees — not on byte equality or pixel height.
It exists to close the verification gap behind issues #463–#472: the byte-golden and height/file-size suites are circular (the goldens were generated from the same implementation under test) or too coarse to notice "License is missing", "files changed is absent", or "the card rendered empty". This package parses the SVG (including the xhtml inside <foreignObject>) with goquery, strips non-rendered nodes (<style>/<defs>/<script>), and exposes the remaining visible text and DOM structure for content-level assertions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains reports whether the visible text contains sub, comparing case-insensitively after whitespace normalization. Returns an error only if the SVG fails to parse.
func Doc ¶
Doc parses raw SVG/HTML bytes into a goquery document with the non-rendered nodes (<style>, <defs>, <script>) removed, so every subsequent query and Text() call sees only content a viewer would actually render.
func MatchCount ¶
MatchCount returns how many times re matches across the visible text (not the raw markup). Use for "does a '<n> files changed' label appear" style structural assertions.
func Normalize ¶
Normalize trims and collapses internal whitespace to single spaces. Exported so callers can normalize an expected marker the same way before a Contains check.
func Tokens ¶
Tokens returns the sorted, de-duplicated, lowercased whitespace tokens of the visible text. Useful for set-subset comparisons between an upstream reference and our output.
func VisibleText ¶
VisibleText returns the document's rendered text content collapsed to single spaces. Style/defs/script have already been stripped by Doc, so CSS rules and `<defs>` payloads do not leak in.
Types ¶
This section is empty.