package text

import "git.sr.ht/~shulhan/pakakeh.go/lib/text"

Package text provide common a library for working with text.

Index

Functions

func JoinChunks

func JoinChunks(chunks []Chunk, sep string) string

JoinChunks all chunk's values using `sep` as separator and return it as string.

Types

type Chunk

type Chunk struct {
	V       []byte
	StartAt int
}

Chunk represent subset of line, contain starting position and slice of bytes in line.

func (Chunk) MarshalJSON

func (chunk Chunk) MarshalJSON() ([]byte, error)

MarshalJSON encode the Chunk into JSON value.

func (Chunk) String

func (chunk Chunk) String() string

type Chunks

type Chunks []Chunk

Chunks represent a set of chunk.

func (*Chunks) Join

func (chunks *Chunks) Join(sep string) (s string)

Join all chunk's values using `sep` as separator and return it.

type Line

type Line struct {
	V []byte
	N int
}

Line represent line number and slice of bytes as string.

func (Line) MarshalJSON

func (line Line) MarshalJSON() ([]byte, error)

MarshalJSON encode the Line into JSON value.

func (Line) String

func (line Line) String() string

type Lines

type Lines []Line

Lines represent array of line.

func ParseLines

func ParseLines(raw []byte) (lines Lines)

ParseLines convert raw bytes into Lines.

Source Files

chunk.go chunks.go line.go lines.go text.go

Directories

PathSynopsis
lib/text/diffPackage diff implement text comparison.
Version
v0.60.0 (latest)
Published
Feb 1, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
2 minutes ago

Tools for package owners.