Documentation
¶
Overview ¶
Package normal normalizes a text as the check kinds of the module format and its leak check do, and reads a number in the notation that a kind takes (format/README.md, sections 15 and 20): the steps 1 to 7 of a number and the units of step 6, the normal form of a choice, and a number in notation as an exact rational. The verdict reads the values read by it, and the leak check the texts it searches, the keys and the leak phrases; it came out of package verdict when the leak check came to need it too (R27, R30).
Its NFKC is golang.org/x/text/unicode/norm, and the version of Unicode that it follows is UnicodeVersion, which package verdict names for a release.
Index ¶
- Constants
- func Choice(text string) string
- func Compared(c formatv0.Check, units []string, text string) (string, bool)
- func Lower(text string) string
- func Number(value string, units []string) string
- func Scripts(text string) string
- func Text(text string) string
- func Unit(unit string) string
- func Units(c formatv0.Check) []string
- type Written
Constants ¶
const MaxNotation = 16
MaxNotation is the length of the longest text in notation. A text in notation is ASCII, so its length in bytes is its length in characters.
const UnicodeVersion = norm.Version
UnicodeVersion is the version of Unicode of the tables of NFKC that the package is built with.
Variables ¶
This section is empty.
Functions ¶
func Choice ¶
Choice gives what a choice compares: the text through NFKC, the dashes and slashes of step 3 and the white space of step 4, and then in lowercase. Nothing more is dropped: a = or a . can be what the learner chose.
func Compared ¶ added in v0.1.23
Compared gives what a check compares a value by, and whether it compares it at all: a choice, its normal form, always; a number, a fraction and a predicate, its value in the kind's notation, exactly, written in lowest terms. units are the forms of a number's units, as Units gives them. The verdict compares a value with the key and the trap values by it, and the comparison of the versions of a module the keys and the trap values of two versions (format/README.md, sections 15 and 27).
func Lower ¶
Lower maps each character to its simple lowercase mapping (UnicodeData.txt, field 13), as unicode.ToLower does, a character at a time: no context counts, as a final sigma's would, and no character becomes two.
func Number ¶
Number gives a value as number, fraction and predicate read it, steps 1 to 7, with units, the forms of a number's units that Unit gives: "" when it is blank.
func Scripts ¶
Scripts takes step 1: every superscript or subscript digit becomes U+FFFD, which no notation takes, and so does every vulgar fraction that a number, a character of the general category N, stands right before or right after in the text as it is, so that NFKC does not make 7² into 72 or 1½ into 11⁄2. The leak check takes the same step (section 20).
func Text ¶
Text takes steps 2 to 4, in their order, so that steps 3 and 4 take what NFKC gives too: NFKC; the hyphens and dashes U+2010 and U+2012 to U+2015 and the minus sign U+2212 become -, the fraction slash U+2044 and the division slash U+2215 become /; and every run of white space, the characters with the property White_Space, becomes one space, with none at either end.
Types ¶
type Written ¶
Written is a number in notation: its value, exactly, and whether it is written in lowest terms, as a simple fraction whose numerator and denominator have no common divisor but 1 is, and an integer or a decimal always is.
func Notation ¶
Notation reads a text in the notation that a kind takes — number all three, fraction a simple fraction, predicate an integer — and says whether it is in it. big.Rat reduces a fraction, so whether it is in lowest terms is read off the numerator and the denominator as they are written.