Documentation ¶
Overview ¶
folder formats header fields, folding lines when needed
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Folder ¶
type Folder struct { Err error // io.Writer error // contains filtered or unexported fields }
func New ¶
New returns folder that supports header folding. Max line length is set to 78 octets, excluding CRLF.
Folder only has 1 line lookahead and respects priority of folding locations over minimising number of folded lines
func (*Folder) Close ¶
func (f *Folder) Close()
Close flushes rest of buffered content and closes header
func (*Folder) Write ¶
func (f *Folder) Write(tokens ...interface{})
Write expects a list of header string values and folding white space integer values, where lower int values takes precedence over higher values.
The positioning of integer values signifies where folding may occur. If no int is specified, no folding will occur.
Tokens can be int, string or Foldable
type MIMEParam ¶
MIMEParam implements RFC 2231 MIME parameter encoding and folding (continuation)
parameter := regular-parameter / extended-parameter regular-parameter := regular-parameter-name "=" value regular-parameter-name := attribute attribute := 1*attribute-char attribute-char := <any (US-ASCII) CHAR except SPACE, CTLs, "*", "'", "%", or tspecials> value := token / quoted-string token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> extended-parameter := (extended-initial-name "=" extended-initial-value) / (extended-other-names "=" extended-other-values) extended-initial-name := attribute [initial-section] "*" extended-initial-value := [charset] "'" [language] "'"extended-other-values extended-other-names := attribute other-sections "*" extended-other-values := *(ext-octet / attribute-char) initial-section := "*0" other-sections := "*" ("1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9") *DIGIT ext-octet := "%" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F") charset := <registered character set name> language := <registered language tag [RFC-1766]>
func (MIMEParam) Fold ¶
Fold performs both encoding and folding, though it probably should not according to Single Responsibility Principle. However since both encoded and folded form have the same extended parameter syntax, we deduplicate work by only accepting unencoded values and deciding whether to encode/fold at the same time
type WordEncodable ¶
type WordEncodable struct { Decoded string Enc mime.WordEncoder MustEncode bool FoldPriority int }
NewWordEncodable represents a managed optionally encodable string that handles folding at a customizable position. This is useful for folding an otherwise long string where a foldable white space may not be present. Non us-ascii will trigger encoding.
func (WordEncodable) Fold ¶
func (w WordEncodable) Fold(limit int) string
func (WordEncodable) Priority ¶
func (w WordEncodable) Priority() int
func (WordEncodable) Value ¶
func (w WordEncodable) Value() string