Help us shape the future of Go! Take the 2026 Go Developer Survey

runechunk

package
v0.19.13 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package runechunk splits and cuts platform text at readable rune boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatFenced added in v0.19.1

func FormatFenced(markdown string, code, prose func(string) string) string

FormatFenced rewrites markdown line by line for platforms that render triple-backtick blocks but would show a fence's language token literally: fence markers become a bare ```, lines inside a fence go through code, and other lines through prose, after an inline ``` span (content on the same line) is downgraded to single backticks so no fence dangles.

func IsFence added in v0.14.0

func IsFence(trimmed string, inFence bool) bool

IsFence reports whether trimmed is a pure code-fence marker: bare ``` always, or ``` plus a single language token when opening a fence. Closing fences carry no info string (CommonMark), and any line with more backticks or extra words is inline content, not a fence.

func LenUTF16 added in v0.14.0

func LenUTF16(s string) int

LenUTF16 counts text in UTF-16 code units, as required by platform limits.

func Split

func Split(text string, limit int) []string

Split cuts text into chunks of at most limit runes, preferring paragraph breaks, then line breaks, then spaces, then a hard cut. Empty input or a non-positive limit yields no chunks.

func SplitLine added in v0.19.1

func SplitLine(line string, limit int, width func(rune) int, html bool) []string

SplitLine cuts one line into pieces of at most limit units, measuring each rune with width, preferring the last space that fits and dropping the spaces around a cut. With html, a cut lands inside a <tag> or a '&…;' escape only when nothing else fits: a cut escape would surface as literal "amp;"-style text that no parse error catches.

func Truncate added in v0.14.0

func Truncate(s string, limit int) string

Truncate cuts s to at most limit runes.

func TruncateUTF16 added in v0.14.0

func TruncateUTF16(s string, limit int) string

TruncateUTF16 cuts at a rune boundary within limit UTF-16 code units.

Types

This section is empty.

Jump to

Keyboard shortcuts

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