bdo

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

The <bdo> HTML element forcibly overrides the bidirectional text algorithm, rendering text in a specific direction regardless of its natural directionality. Used when you need to explicitly control text direction for special formatting, displaying code examples, or showing text in an intentionally reversed manner. Requires the dir attribute to specify the override direction.

Index

Constants

This section is empty.

Variables

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

	AttrDir = []byte(" dir=\"")
)

Byte constants for HTML rendering.

Functions

func New

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

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

func RawText

func RawText(str string) *element

RawText creates a new bdo element with raw text content as unescaped HTML. Example: bdo.RawText("<em>Text</em>").Dir(dir.RightToLeft) Renders: <bdo dir="rtl"><em>Text</em></bdo>

func RawTextf

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

RawTextf creates a new bdo element with formatted raw text content as unescaped HTML using text.RawTextf. Example: bdo.RawTextf("<strong>%s</strong>", "Text").Dir(dir.RightToLeft) Renders: <bdo dir="rtl"><strong>Text</strong></bdo>

func Static

func Static(str string) *element

Static creates a new bdo element with static text content. Example: bdo.Static("ABC").Dir(dir.LeftToRight) Renders: <bdo dir="ltr">ABC</bdo>

func Text

func Text(str string) *element

Text creates a new bdo element with text content (HTML-encoded). Example: bdo.Text("Hello World").Dir(dir.RightToLeft) Renders: <bdo dir="rtl">Hello World</bdo>

func Textf

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

Textf creates a new bdo element with formatted text content using text.Textf. Example: bdo.Textf("Hello %s", "World").Dir(dir.RightToLeft) Renders: <bdo dir="rtl">Hello World</bdo>

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