Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxIter = 100
Functions ¶
Types ¶
type Cutter ¶ added in v0.1.81
type Cutter struct {
Sep string
}
Cutter splits the input by the given separator and keeps only the part before it.
type LineToParagraph ¶ added in v0.1.83
type LineToParagraph struct {
// TrimSpace controls whether leading and trailing spaces are removed from each line.
// true → trim spaces
// false → preserve spaces (default, matches previous behaviour)
TrimSpace bool
// SkipEmpty controls whether completely empty lines produce <p></p> or are ignored.
// true → skip empty lines (default, matches previous behaviour)
// false → emit <p></p> for empty lines
SkipEmpty bool
}
LineToParagraph converts each line of text into a separate HTML <p>...</p> paragraph. TrimSpace controls whether leading and trailing spaces are removed from each line before wrapping it in <p> tags. Empty lines can be either skipped or rendered as empty <p></p> according to the SkipEmpty flag.
func (LineToParagraph) Describe ¶ added in v0.1.83
func (p LineToParagraph) Describe() string
Describe returns a human-readable description of the processor.
func (LineToParagraph) Once ¶ added in v0.1.83
func (LineToParagraph) Once() bool
Once returns true – the transformation is idempotent and should run only once.
type Processor ¶
type Processor interface {
// Describe returns a short description of this processor.
Describe() string
// Once reports whether this processor should run only once.
Once() bool
// Process performs the actual text transformation.
Process(string) (string, error)
}
Processor defines a generic interface for text processors. Each processor can optionally be executed only once (Once == true) and provides a human-readable description for debugging or logging.
func CutSpace ¶ added in v0.1.81
func CutSpace() Processor
CutSpace returns a processor that extracts the first word in the input string.
func NewMultiProcessor ¶ added in v0.1.81
NewMultiProcessor creates a new MultiProcessor.
desc - human-readable name once - whether this processor should execute only once procs - list of sub-processors
func NewProcessor ¶
NewProcessor creates a new Processor from a function.
desc - short description for debugging once - whether this processor should be executed only once fn - transformation function taking a string and returning a string/error
func RemoveParentheses ¶ added in v0.1.81
func RemoveParentheses() Processor
RemoveParentheses returns a processor that remove both western and full-width parentheses.
func ToParagraphs ¶ added in v0.1.83
ToParagraphs returns a processor that converts each line into a <p> paragraph. If skipEmpty is true, empty lines are ignored; otherwise, they produce empty <p></p>.
type RegexpRemover ¶ added in v0.1.81
RegexpRemover removes substrings that match the given regular expression.
func (RegexpRemover) Describe ¶ added in v0.1.81
func (p RegexpRemover) Describe() string
Describe returns a string representation of the RegexpRemover.
func (RegexpRemover) Once ¶ added in v0.1.81
func (RegexpRemover) Once() bool
Once always returns false, meaning this processor can be applied repeatedly.
type Tasks ¶
type Tasks struct {
// contains filtered or unexported fields
}
Tasks represents an ordered list of text processors. Each processor in the list will be executed sequentially, and repeated until the text no longer changes.
func (*Tasks) Append ¶
Append adds one or more processors to the task list and returns the updated instance.
type Trimmer ¶ added in v0.1.81
type Trimmer struct {
Cutset string
}
Trimmer removes all leading and trailing characters from the given cutset.