htmltext

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FontStyleCSS

func FontStyleCSS(fs *rich.Style, tag string, cssProps map[string]any) bool

FontStyleCSS looks for "tag" name properties in cssProps properties, and applies those to style if found, and returns true -- false if no such tag found

func HTMLPreToRich

func HTMLPreToRich(str []byte, sty *rich.Style, cssProps map[string]any) (rich.Text, error)

HTMLPreToRich translates preformatted HTML-styled text into a rich.Text using given initial text styling parameters and css properties. This uses a custom decoder that preserves all whitespace characters, and decodes all standard inline HTML text style formatting tags in the string. Only basic styling tags, including <span> elements with style parameters (including class names) are decoded. Whitespace is decoded as-is, including LF \n etc, except in WhiteSpacePreLine case which only preserves LF's.

func HTMLToRich

func HTMLToRich(str []byte, sty *rich.Style, cssProps map[string]any) (rich.Text, error)

HTMLToRich translates HTML-formatted rich text into a rich.Text, using given initial text styling parameters and css properties. This uses the golang XML decoder system, which strips all whitespace and therefore does not capture any preformatted text. See HTMLPre. cssProps are a list of css key-value pairs that are used to set styling properties for the text, and can include class names with a value of another property map that is applied to elements of that class, including standard elements like a for links, etc.

func RichToHTML

func RichToHTML(tx rich.Text) string

RichToHTML returns an HTML encoded representation of the rich.Text.

func SubProperties

func SubProperties(tag string, cssProps map[string]any) (map[string]any, bool)

SubProperties returns a properties map[string]any from given key tag of given properties map, if the key exists and the value is a sub props map. Otherwise returns nil, false

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL