Documentation
¶
Overview ¶
Package contentline reads and patches the content lines of vCard (RFC 6350) and iCalendar (RFC 5545) objects. Parse keeps each property's place in the source, so a change replaces the lines it touches and leaves every other byte as the server sent it (ADR-0018).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSyntax = errors.New("contentline: syntax error")
ErrSyntax wraps every parse error.
Functions ¶
func Apply ¶
Apply returns src with the edits made. Edits may come in any order but must not overlap; two insertions at the same place keep their order, and an insertion goes before an edit that replaces text starting there.
func EscapeText ¶
EscapeText escapes a TEXT value: backslash, semicolon, comma and newline (RFC 5545 §3.3.11). Carriage returns are dropped.
func Fold ¶
Fold splits a logical line into lines of at most 75 octets, never inside a UTF-8 sequence; each continuation starts with a space, and every line ends in eol.
func JoinFields ¶
JoinFields escapes each field and joins them with semicolons, for N, ADR and ORG.
func LineEnding ¶
LineEnding returns the line ending src uses: "\n" when its first line ends in a bare LF, else "\r\n".
Types ¶
type Component ¶
type Component struct {
Name string // uppercased
Props []Prop // the component's own properties, without BEGIN and END
Children []*Component
// Start and End are the block's bytes in the source, from its BEGIN
// line to its END line's line ending.
Start, End int
}
Component is a BEGIN/END block: a VCARD, VCALENDAR, VEVENT, VALARM, ….
func Parse ¶
Parse reads the top-level components in src. Lines end in CRLF or LF; a line that starts with a space or tab continues the one before it. Empty lines are skipped.
func (*Component) ChildrenNamed ¶
ChildrenNamed returns the component's children with the name, in order.
func (*Component) PropsNamed ¶
PropsNamed returns the component's properties with the name, in order.
type Param ¶
type Param struct {
Name string // uppercased
Values []string // unquoted, RFC 6868 caret escapes decoded
}
Param is one property parameter. A parameter may repeat; each occurrence is its own Param.
type Prop ¶
type Prop struct {
Group string // the vCard group, such as item1; empty when there is none
Name string // uppercased
Params []Param // in source order
Value string // as written: escapes intact
// Start and End are the folded line's bytes in the source, its line
// ending included.
Start, End int
}
Prop is one property: a content line, unfolded.
func (Prop) Encode ¶
Encode formats the property as content lines folded at 75 octets, each ending in eol ("\r\n", or "\n" to match a source that uses it). Start and End are ignored.
func (Prop) Fields ¶
Fields splits a structured value (N, ADR, ORG, GENDER) at unescaped semicolons and unescapes each field.
func (Prop) ParamValues ¶
ParamValues returns every value of the named parameter across its occurrences, with comma-separated values split (TYPE=work,voice).