Documentation
¶
Overview ¶
Package abbr provides constructors and methods for the HTML <abbr> element.
The <abbr>: The Abbreviation element represents an abbreviation or acronym. When including an abbreviation or acronym, provide a full expansion of the term in plain text on first use, along with the <abbr> to mark up the abbreviation. This informs the user what the abbreviation or acronym means.
Index ¶
- Variables
- func New(nodes ...node.Node) *element
- func RawText(abbreviation string) *element
- func RawTextf(format string, args ...any) *element
- func Static(abbreviation string) *element
- func Text(abbreviation string) *element
- func Textf(format string, args ...any) *element
- func Titled(abbreviation string, title string) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<abbr") TagClose = []byte("</abbr>") AttrTitle = []byte(" title=\"") )
Byte constants for HTML rendering.
Functions ¶
func New ¶
New creates a new abbreviation element without any initial attributes. Use for basic abbreviations where semantic markup is needed. Example: abbr.New() Renders: <abbr></abbr>
func RawText ¶
func RawText(abbreviation string) *element
RawText creates a new abbreviation element with raw text content. Uses text.RawText which is not HTML-escaped. Example: abbr.RawText("<strong>HTML</strong>") Renders: <abbr><strong>HTML</strong></abbr>
func RawTextf ¶
RawTextf creates a new abbreviation element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: abbr.RawTextf("<b>%s</b>", "HTML") Renders: <abbr><b>HTML</b></abbr>
func Static ¶
func Static(abbreviation string) *element
Static creates a new abbreviation element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: abbr.Static("HTML") Renders: <abbr>HTML</abbr>
func Text ¶
func Text(abbreviation string) *element
Text creates a new abbreviation element with text content. Uses text.Text which HTML-escapes the output. Example: abbr.Text("HTML") Renders: <abbr>HTML</abbr>
func Textf ¶
Textf creates a new abbreviation element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: abbr.Textf("v%d", 2) Renders: <abbr>v2</abbr>
func Titled ¶
Titled creates a new abbreviation element with both the abbreviation text and its full expansion in the title attribute. This is the recommended approach for accessibility as it provides the expansion on hover. Example: abbr.Titled("HTML", "HyperText Markup Language") Renders: <abbr title="HyperText Markup Language">HTML</abbr>