Documentation
¶
Overview ¶
Package ins provides constructors and methods for the HTML <ins> element.
The <ins> HTML element represents a range of text that has been added to a document. You can use the <del> element to similarly represent a range of text that has been deleted from 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("<ins") TagClose = []byte("</ins>") AttrCite = []byte(" cite=\"") AttrDateTime = []byte(" datetime=\"") )
Byte constants for HTML rendering.
Functions ¶
func Cited ¶ added in v0.3.0
Cited creates an ins element with text content and a URL documenting the reason for the insertion. Uses text.Text which HTML-escapes the output. Example: ins.Cited("new paragraph", "/changelog#v2.2") Renders: <ins cite="/changelog#v2.2">new paragraph</ins>
func Dated ¶ added in v0.3.0
Dated creates an ins element with text content and a timestamp indicating when the insertion occurred. Uses text.Text which HTML-escapes the output. Example: ins.Dated("new price: $40", "2024-01-15") Renders: <ins datetime="2024-01-15">new price: $40</ins>
func Full ¶ added in v0.3.0
Full creates an ins element with text content, a citation URL, and a timestamp. Use when recording both why and when content was added. Uses text.Text which HTML-escapes the output. Example: ins.Full("new price: $40", "/changelog", "2024-01-15") Renders: <ins cite="/changelog" datetime="2024-01-15">new price: $40</ins>
func New ¶
New creates a new ins element with optional child nodes. Example: ins.New() Renders: <ins></ins>
func RawText ¶
func RawText(str string) *element
RawText creates a new ins element with raw text content. Uses text.RawText which is not HTML-escaped. Example: ins.RawText("<p>New paragraph added.</p>") Renders: <ins><p>New paragraph added.</p></ins>
func RawTextf ¶
RawTextf creates a new ins element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: ins.RawTextf("<strong>%s</strong>", newText) Renders: <ins><strong>updated</strong></ins>
func Static ¶
func Static(str string) *element
Static creates a new ins element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: ins.Static("This section was added.") Renders: <ins>This section was added.</ins>