readme

package
v1.9.12 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package readme provides functions for reading and suggesting readme files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchANSI added in v1.9.1

func MatchANSI(r io.Reader) (bool, error)

MatchANSI scans for HTML incompatible, ANSI cursor escape codes in the reader.

func ReadPool added in v1.7.7

func ReadPool(
	art *models.File, sizeLimit int64, download, extra dir.Directory,
) (*bytes.Buffer, *bytes.Buffer, sauce.Record, error)

ReadPool returns the content of the readme file or the text of the file download. The first buffer is used for CP1252 and ISO-8859-1 texts while the second buffer is used for UTF-8 texts.

The CP1252 and ISO-8859-1 Buffer may also include a FILE_ID.DIZ prefixed metadata. However, the UTF-8 Buffer does get the FILE_ID.DIZ prefix.

func RemoveCtrls

func RemoveCtrls(b []byte) []byte

RemoveCtrls removes ANSI escape codes and converts Windows line endings to Unix.

func SortList added in v1.9.11

func SortList(compact bool, content string) []string

SortList returns a sorted list of possible readme text files found in the file archive. The first result is the closes filename to root that has a priority filename extension such as ".nfo", then ordered alphabetically.

When compact is true all filenames using extensions that are not known textfiles, are removed from the slice.

To save memory, content is not split into a slice until we need to handle it.

func Suggest

func Suggest(archive, group string, content string) string

Suggest returns a suggested readme file name for the record. It prioritizes the filename and group name with a priority extension, such as ".nfo", ".txt", etc. If no priority extension is found, it will return the first text file in the content list.

The archive should be the filename of the archive artifact such as the zip filename. The group should be a name or common abbreviation of the group that released the artifact. The content should be a list of files contained in the artifact.

To save memory, content is not split into a slice until we need to handle it.

This is a port of the CFML function, variables.findTextfile found in File.cfc.

Types

This section is empty.

Jump to

Keyboard shortcuts

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