split

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

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

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

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

Variables

This section is empty.

Functions

func Bars

func Bars(src []byte) []string

Bars 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.Bars(b))
	fmt.Printf("Color sequences: %d", l)
}
Output:
Color sequences: 3

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 HTMLBars

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

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

func HTMLCelerity

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

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

func HTMLPCBoard

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

HTMLPCBoard parses the string for the common PCBoard 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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