ins

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func Cited(str string, cite string) *element

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

func Dated(str string, datetime string) *element

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

func Full(str string, cite string, datetime string) *element

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

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

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

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

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>

func Text

func Text(str string) *element

Text creates a new ins element with text content. Uses text.Text which HTML-escapes the output. Example: ins.Text("new price: $40") Renders: <ins>new price: $40</ins>

func Textf

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

Textf creates a new ins element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: ins.Textf("price: $%d", newPrice) Renders: <ins>price: $30</ins>

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