split

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// CelerityRe is a regular expression to match Celerity BBS color codes.
	CelerityRe string = `\|(k|b|g|c|r|m|y|w|d|B|G|C|R|M|Y|W|S)`

	// PCBoardRe is a case-insensitive, regular expression to match PCBoard BBS color codes.
	PCBoardRe string = "(?i)@X([0-9A-F][0-9A-F])"

	// VBarsRe is a regular expression to match Renegade BBS color codes.
	VBarsRe string = `\|(0[0-9]|1[1-9]|2[0-3])`
)

Variables

View Source
var ErrBuff = errors.New("bytes buffer cannot be nil")

Functions

func Celerity

func Celerity(src []byte) []string

Celerity slices a string into substrings separated by "|" vertical bar codes. The first byte of each substring will contain a Celerity colour value, that are comprised of a single, alphabetic character. An empty slice is returned when no valid Celerity code values exists.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/bbs/internal/split"
)

func main() {
	b := []byte("|cHello |C|S|wworld")
	l := len(split.Celerity(b))
	fmt.Printf("Color sequences: %d", l)
}
Output:

Color sequences: 4

func CelerityHTML added in v1.0.0

func CelerityHTML(dst *bytes.Buffer, src []byte) error

CelerityHTML parses the string for the unique Celerity BBS color codes to apply a HTML template.

func PCBoard

func PCBoard(src []byte) []string

PCBoard slices a string into substrings separated by PCBoard @X codes. The first two bytes of each substring will contain background and foreground hex colour values. An empty slice is returned when no valid @X code values exists.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/bbs/internal/split"
)

func main() {
	s := []byte("@X03Hello world")
	l := len(split.PCBoard(s))
	fmt.Printf("Color sequences: %d", l)
}
Output:

Color sequences: 1

func PCBoardHTML added in v1.0.0

func PCBoardHTML(dst *bytes.Buffer, src []byte) error

PCBoardHTML parses the string for the common PCBoard BBS color codes to apply a HTML template.

func VBars added in v1.0.0

func VBars(src []byte) []string

VBars slices a string into substrings separated by "|" vertical bar codes. The first two bytes of each substring will contain a colour value. Vertical bar codes are used by Renegade, WWIV hash and WWIV heart formats. An empty slice is returned when no valid bar code values exists.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/bbs/internal/split"
)

func main() {
	b := []byte("|03Hello |07|19world")
	l := len(split.VBars(b))
	fmt.Printf("Color sequences: %d", l)
}
Output:

Color sequences: 3

func VBarsHTML added in v1.0.0

func VBarsHTML(dst *bytes.Buffer, src []byte) error

VBarsHTML parses the string for BBS color codes that use vertical bar prefixes to apply a HTML template.

Types

This section is empty.

Jump to

Keyboard shortcuts

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