Documentation
¶
Overview ¶
Package whitespace finds the spaces out of place in a name: doubled, at an end, odd, or before a colon or a file extension. It says what is wrong (Problems), shows it (Visible) and puts it right (Fixed). What is wrong depends on the kind of text (Text): a file name has an extension, and a French title keeps its space before a colon.
Index ¶
- Constants
- Variables
- func Any(r rune) bool
- func DroppedAt(name, title string) string
- func EndsWithSpace(s string) bool
- func Fixed(name string, k Text) string
- func IndexWord(s, word string) int
- func IsWordChar(r rune) bool
- func Odd(r rune) bool
- func Problems(name string, k Text) []string
- func SplitExt(name string) (stem, ext string)
- func StartsWithSpace(s string) bool
- func Typographic(r rune) bool
- func Visible(name string, k Text) string
- type Text
Constants ¶
const ( OddSpace = "odd_space" DoubleSpace = "double_space" EdgeSpace = "edge_space" BeforeExtension = "space_before_extension" BeforeColon = "space_before_colon" )
The problems, named as Problems reports them, in the order it reports them.
Variables ¶
var ProblemOrder = []string{OddSpace, DoubleSpace, EdgeSpace, BeforeExtension, BeforeColon}
ProblemOrder is every problem, in the order Problems lists them.
Functions ¶
func DroppedAt ¶
DroppedAt is what a title holds where a name has two spaces in a row, when the words either side are in the title: ":" for "Dune Part Two" against "Dune: Part Two". "" when they do not line up, or the gap holds more than a few words, which is another name.
func EndsWithSpace ¶
EndsWithSpace says whether a text ends with a space of any kind.
func Fixed ¶
Fixed is a text with its spaces put right; "" when nothing is left but spaces or an extension, since ".mkv" would read as a hidden file.
func IndexWord ¶
IndexWord is where word first stands in s as a word of its own ("IV" in "Episode IV", not in "DIVE"); -1 for nowhere.
func Odd ¶
Odd is a space that is not the ordinary one: a tab, a line break, a non-breaking or typographic space. The ideographic space, U+3000, is not one: Japanese titles use it as written.
func Problems ¶
Problems is what is wrong with the spaces in one text, in ProblemOrder; nothing for a text whose spaces are all in place.
func SplitExt ¶
SplitExt parts a file name into stem and extension; a last dot that starts no plausible extension (over five letters, or with a space) is all stem. Trailing spaces are read as neither, so one after the extension hides none before it.
func StartsWithSpace ¶
StartsWithSpace says whether a text begins with a space of any kind.
func Typographic ¶
Typographic is a no-break or narrow space a language's own typography sets on purpose: French puts one before a colon ("Titre : Sous-titre").
Types ¶
type Text ¶
type Text int
Text is what a text is, which decides what is wrong with its spaces.
const ( // Name is a name or a value: every problem counts Name Text = iota // File is a file name, read as a stem and an extension File // Foreign is an original title, written in its own language: the space before a colon and the typographic spaces that language's typography sets // are left alone, and only the rest is a problem Foreign )