Documentation ¶
Overview ¶
Package parse contains a collection of parsers for various formats in its subpackages.
Index ¶
- Variables
- func Copy(src []byte) (dst []byte)
- func DataURI(dataURI []byte) ([]byte, []byte, error)
- func Dimension(b []byte) (int, int)
- func EqualFold(s, targetLower []byte) bool
- func IsAllWhitespace(b []byte) bool
- func IsNewline(c byte) bool
- func IsWhitespace(c byte) bool
- func Mediatype(b []byte) ([]byte, map[string]string)
- func Number(b []byte) int
- func Position(r io.Reader, offset int) (line, col int, context string)
- func ReplaceEntities(b []byte, entities map[string]byte) []byte
- func ReplaceMultipleWhitespace(b []byte) []byte
- func ToLower(src []byte) []byte
- func TrimWhitespace(b []byte) []byte
- type Error
Constants ¶
This section is empty.
Variables ¶
var ErrBadDataURI = errors.New("not a data URI")
ErrBadDataURI is returned by DataURI when the byte slice does not start with 'data:' or is too short.
Functions ¶
func EqualFold ¶
EqualFold returns true when s matches case-insensitively the targetLower (which must be lowercase).
func IsAllWhitespace ¶
IsAllWhitespace returns true when the entire byte slice consists of space, \n, \r, \t, \f.
func IsWhitespace ¶
IsWhitespace returns true for space, \n, \r, \t, \f.
func Mediatype ¶
Mediatype parses a given mediatype and splits the mimetype from the parameters. It works similar to mime.ParseMediaType but is faster.
func Number ¶
Number returns the number of bytes that parse as a number of the regex format (+|-)?([0-9]+(\.[0-9]+)?|\.[0-9]+)((e|E)(+|-)?[0-9]+)?.
func Position ¶
Position returns the line and column number for a certain position in a file. It is useful for recovering the position in a file that caused an error. It only treates \n, \r, and \r\n as newlines, which might be different from some languages also recognizing \f, \u2028, and \u2029 to be newlines.
func ReplaceEntities ¶ added in v2.3.11
ReplaceEntities replaces all occurrences of entites (such as ") to their respective unencoded bytes.
func ReplaceMultipleWhitespace ¶
ReplaceMultipleWhitespace replaces character series of space, \n, \t, \f, \r into a single space or newline (when the serie contained a \n or \r).
func TrimWhitespace ¶
TrimWhitespace removes any leading and trailing whitespace characters.
Types ¶
type Error ¶
Error is a parsing error returned by parser. It contains a message and an offset at which the error occurred.
func NewErrorLexer ¶
NewErrorLexer creates a new error from an active Lexer.
Directories ¶
Path | Synopsis |
---|---|
Package buffer contains buffer and wrapper types for byte slices.
|
Package buffer contains buffer and wrapper types for byte slices. |
Package css is a CSS3 lexer and parser following the specifications at http://www.w3.org/TR/css-syntax-3/.
|
Package css is a CSS3 lexer and parser following the specifications at http://www.w3.org/TR/css-syntax-3/. |
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html.
|
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html. |
Package js is an ECMAScript5.1 lexer following the specifications at http://www.ecma-international.org/ecma-262/5.1/.
|
Package js is an ECMAScript5.1 lexer following the specifications at http://www.ecma-international.org/ecma-262/5.1/. |
Package json is a JSON parser following the specifications at http://json.org/.
|
Package json is a JSON parser following the specifications at http://json.org/. |
Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/.
|
Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/. |