chunk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package chunk places cache-friendly boundaries within a single logical line of text. Callers use each chunk's bytes as the key of a per-chunk segmentation cache: an edit confined to one chunk re-segments only that chunk rather than the whole line.

Every boundary is at once a UAX #29 grapheme boundary, a UAX #29 word boundary, and a UAX #14 line-break opportunity. Cuts fall only at breakable whitespace or sentence terminators, are snapped past trailing combining marks and format characters, and are placed only where the next chunk begins with letter or number content. That keeps per-chunk segmentation equal to whole-line segmentation for all three boundary kinds — a cut landing mid-segment would inject a boundary the whole-line pass would not have. Boundary placement is a pure function of the input; it is independent of width, wrap mode, and any layout state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBoundaries

func AppendBoundaries(dst []int, s string) []int

AppendBoundaries appends to dst the exclusive end byte offset of each chunk of s and returns the extended slice. The chunks partition s: chunk i spans s[start:b[i]] where b is the appended boundaries, start is the previous boundary, and 0 for the first chunk. The last appended boundary is always len(s). An empty s yields a single boundary of 0 (one empty chunk).

Types

This section is empty.

Jump to

Keyboard shortcuts

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