Documentation
¶
Overview ¶
Package dfn provides constructors and methods for the HTML <dfn> element.
The <dfn> HTML element indicates a term to be defined. The <dfn> element should be used in a complete definition statement, where the full definition of the term can be one of the following:
Index ¶
- Variables
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func Static(str string) *element
- func Text(str string) *element
- func Textf(format string, args ...any) *element
- func Titled(str string, title string) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<dfn") TagClose = []byte("</dfn>") AttrTitle = []byte(" title=\"") )
Byte constants for HTML rendering.
Functions ¶
func New ¶
New creates a new dfn element with the given child nodes. Example: dfn.New(text.Text("validator")) Renders: <dfn>validator</dfn>
func RawText ¶
func RawText(str string) *element
RawText creates a new dfn element with raw text content. Uses text.RawText which is not HTML-escaped. Example: dfn.RawText("<b>validator</b>") Renders: <dfn><b>validator</b></dfn>
func RawTextf ¶
RawTextf creates a new dfn element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: dfn.RawTextf("<abbr>%s</abbr>", term) Renders: <dfn><abbr>HTML</abbr></dfn>
func Static ¶
func Static(str string) *element
Static creates a new dfn element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: dfn.Static("Validator") Renders: <dfn>Validator</dfn>
func Text ¶
func Text(str string) *element
Text creates a new dfn element with text content. Uses text.Text which HTML-escapes the output. Example: dfn.Text("validator") Renders: <dfn>validator</dfn>
func Textf ¶
Textf creates a new dfn element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: dfn.Textf("%s v%d", term, ver) Renders: <dfn>HTML v2</dfn>
func Titled ¶ added in v0.3.0
Titled creates a new dfn element with the term text and an expanded title. The title provides an alternative form or full expansion of the term being defined. Uses text.Text which HTML-escapes the output. Example: dfn.Titled("spec", "Specification") Renders: <dfn title="Specification">spec</dfn>