abbr

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<abbr")
	TagClose = []byte("</abbr>")

	AttrTitle = []byte(" title=\"")
)

Byte constants for HTML rendering.

Functions

func New

func New(nodes ...node.Node) *element

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

func RawTextf(format string, args ...any) *element

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

func Textf(format string, args ...any) *element

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

func Titled(abbreviation string, title string) *element

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>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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