rp

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 rp provides constructors and methods for the HTML <rp> element.

The <rp> HTML element provides fallback parentheses for browsers that don't support ruby annotations. Used exclusively within <ruby> elements to wrap parentheses that surround <rt> elements. Browsers that support ruby annotations hide this content, while older browsers display it to provide context for the ruby text. Essential for proper degradation of ruby annotations in legacy browsers.

Index

Constants

This section is empty.

Variables

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

Byte constants for HTML rendering.

Functions

func New

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

New creates a new rp element with optional child nodes. Example: rp.New(text.Text("(")) Renders: <rp>(</rp>

func RawText

func RawText(content string) *element

RawText creates a new rp element with raw text content. Uses text.RawText which is not HTML-escaped. Example: rp.RawText("<span>(</span>") Renders: <rp><span>(</span></rp>

func RawTextf

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

RawTextf creates a new rp element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: rp.RawTextf("<span>%s</span>", bracket) Renders: <rp><span>(</span></rp>

func Static

func Static(content string) *element

Static creates a new rp element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: rp.Static(")") Renders: <rp>)</rp>

func Text

func Text(content string) *element

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

func Textf

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

Textf creates a new rp element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: rp.Textf("%s", bracket) Renders: <rp>(</rp>

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