Documentation
¶
Overview ¶
Package whitespace finds the spaces out of place in a name: doubled, leading, trailing and odd spaces, and a space before a colon or a file extension. For each name it says what is wrong (Problems), shows it with the offending spaces made visible (Visible) and puts it right (Fixed).
Names come in kinds (Text), because what is wrong depends on what the text is: a file name has an extension a space can sit before, and a title in its own language keeps the spaces its typography sets - French puts one 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 of the gap are in the title too: ":" for "Dune Part Two" written with two spaces against "Dune: Part Two", the asterisks of a censored word. "" when the two do not line up, or the title holds nothing there, or more than a few words - which is another name rather than a character a renamer dropped.
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: an odd space made an ordinary one, runs made one, the ends and the space before a colon or the extension dropped.
func IndexWord ¶
IndexWord is where word first stands in s as a word of its own, and not inside a longer one ("IV" in "Episode IV", not in "DIVE"); -1 when it does not.
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 its stem and its extension; a name whose last dot starts no plausible extension (longer than five letters, or with a space in it) is all stem.
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 )