textutil

package module
v0.0.0-...-177c26d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EndLine = "\n"

Variables

This section is empty.

Functions

func HTMLTable

func HTMLTable(tc TabbedConfig) func(string) (string, error)

func JSONEscape

func JSONEscape(tc TabbedConfig) func(string) (string, error)

func JSONUnescape

func JSONUnescape(tc TabbedConfig) func(string) (string, error)

func NewTabFixer

func NewTabFixer(tabLen int) func(Gridder) (string, error)

func SQLEscape

func SQLEscape(tabLen int) func(string) (string, error)

func SQLInsert

func SQLInsert(tc TabbedConfig) func(Gridder) (string, error)

func SQLUnescape

func SQLUnescape(tabLen int) func(string) (string, error)

Types

type Gridder

type Gridder interface {
	Grid() (grid [][]string, maxColLengths []int)
}

Gridder transforms into a grid of text fields.

This is a "hack" to deal with the original implementations of table parsers expecting the source to be TSV strings. Now when textutil is wrapped by another library, you can use the PassThruGridder to skip any string re-parsing issues

type PassThruGridder

type PassThruGridder struct {
	G [][]string
}

PassThruGridder "passes through" its grid

func (PassThruGridder) Grid

func (pg PassThruGridder) Grid() (grid [][]string, maxColLengths []int)

type TabbedConfig

type TabbedConfig struct {
	TabSize int
	Props   map[string]any
}

type TextSplitGridder

type TextSplitGridder struct {
	Text     string
	LineSep  string
	FieldSep string
}

TextSplitGridder splits a single long string of text into records and fields in those records.

func (TextSplitGridder) Grid

func (sg TextSplitGridder) Grid() (grid [][]string, maxColLengths []int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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