hyphen

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package hyphen hyphenates text using existing Hunspell hyphenation dictionaries.

This is a port of https://github.com/Kozea/Pyphen

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LanguageFallback

func LanguageFallback(lang language.Language) language.Language

Get a fallback language available in our dictionaries.

http://www.unicode.org/reports/tr35/#Locale_Inheritance

We use the normal truncation inheritance. This function needs aliases including scripts for languages with multiple regions available.

Types

type Data

type Data struct {
	//  a string like `'ff=f'`, that describes how hyphenation should
	//  take place.
	Changes [2]string
	//  where to substitute the change, counting from the current point
	Index int
	//  how many characters to remove while substituting the nonstandard
	//  hyphenation
	Cut int
}

Data stores information about nonstandard hyphenation at a point.

type DataInt

type DataInt struct {
	Data *Data // optional
	V    int
}

type HyphDic

type HyphDic struct {
	// contains filtered or unexported fields
}

type HyphDicReference

type HyphDicReference struct {
	Patterns  map[string]Pattern
	MaxLength int // in runes
}

type Hyphener

type Hyphener struct {
	// contains filtered or unexported fields
}

func NewHyphener

func NewHyphener(lang language.Language, left, right int) Hyphener

func (Hyphener) Iterate

func (h Hyphener) Iterate(word string) []string

Iterates over all hyphenation possibilities, the longest first, for `word`. The returned slice contains the starts of each possibility.

type Pattern

type Pattern struct {
	Values []DataInt
	Start  int
}

Jump to

Keyboard shortcuts

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