readme

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: GPL-3.0 Imports: 14 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 IncompatibleANSI

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

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

func List

func List(content ...string) []string

List returns a list of readme text files found in the file archive.

func Read

func Read(art *models.File, downloadPath, extraPath string) ([]byte, error)

Read returns the content of the readme file or the text of the file download.

func RemoveCtrls

func RemoveCtrls(b []byte) []byte

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

func SortContent

func SortContent(content ...string) []string

SortContent sorts the content list by the number of slashes in each string. It prioritizes strings with fewer slashes (i.e., closer to the root). If the number of slashes is the same, it sorts alphabetically.

func Suggest

func Suggest(filename, 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 textfile in the content list.

The filename should be the name of the file archive artifact. 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.

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