Documentation
¶
Overview ¶
Package runechunk splits and cuts platform text at readable rune boundaries.
Index ¶
- func FormatFenced(markdown string, code, prose func(string) string) string
- func IsFence(trimmed string, inFence bool) bool
- func LenUTF16(s string) int
- func Split(text string, limit int) []string
- func SplitLine(line string, limit int, width func(rune) int, html bool) []string
- func Truncate(s string, limit int) string
- func TruncateUTF16(s string, limit int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatFenced ¶ added in v0.19.1
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
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
LenUTF16 counts text in UTF-16 code units, as required by platform limits.
func Split ¶
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
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 TruncateUTF16 ¶ added in v0.14.0
TruncateUTF16 cuts at a rune boundary within limit UTF-16 code units.
Types ¶
This section is empty.