Documentation
¶
Overview ¶
Package del provides constructors and methods for the HTML <del> element.
The <del> HTML element represents a range of text that has been deleted from a document. This can be used when rendering "track changes" or source code diff information, for example. The <ins> element can be used for the opposite purpose: to indicate text that has been added to the document.
Index ¶
- Variables
- func Cited(str string, cite string) *element
- func Dated(str string, datetime string) *element
- func Full(str string, cite string, datetime string) *element
- 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
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<del") TagClose = []byte("</del>") AttrCite = []byte(" cite=\"") AttrDateTime = []byte(" datetime=\"") )
Byte constants for HTML rendering.
Functions ¶
func Cited ¶ added in v0.3.0
Cited creates a del element with text content and a URL documenting the reason for the deletion. Uses text.Text which HTML-escapes the output. Example: del.Cited("removed paragraph", "/changelog#v2.1") Renders: <del cite="/changelog#v2.1">removed paragraph</del>
func Dated ¶ added in v0.3.0
Dated creates a del element with text content and a timestamp indicating when the deletion occurred. Uses text.Text which HTML-escapes the output. Example: del.Dated("old price: $50", "2024-01-15") Renders: <del datetime="2024-01-15">old price: $50</del>
func Full ¶ added in v0.3.0
Full creates a del element with text content, a citation URL, and a timestamp. Use when recording both why and when content was deleted. Uses text.Text which HTML-escapes the output. Example: del.Full("old price: $50", "/changelog", "2024-01-15") Renders: <del cite="/changelog" datetime="2024-01-15">old price: $50</del>
func New ¶
New creates a new del element with optional child nodes. Example: del.New() Renders: <del></del>
func RawText ¶
func RawText(str string) *element
RawText creates a new del element with raw text content. Uses text.RawText which is not HTML-escaped. Example: del.RawText("<s>old price: $50</s>") Renders: <del><s>old price: $50</s></del>
func RawTextf ¶
RawTextf creates a new del element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: del.RawTextf("<s>%s</s>", oldText) Renders: <del><s>removed</s></del>
func Static ¶
func Static(str string) *element
Static creates a new del element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: del.Static("This feature has been removed.") Renders: <del>This feature has been removed.</del>