Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeJSON(data []byte) (types.Twt, error)
- func NewLexer(r io.Reader) *lexer
- func NewParser(l *lexer) *parser
- func NewTwtFile(twter types.Twter, comments Comments, twts types.Twts) *lextwtFile
- func ParseFile(r io.Reader, twter *types.Twter) (types.TwtFile, error)
- func ParseLine(line string, twter *types.Twter) (twt types.Twt, err error)
- type Code
- type CodeType
- type Comment
- type Comments
- type DateTime
- type Elem
- type Line
- type Link
- func (n *Link) Clone() Elem
- func (n *Link) Format(state fmt.State, r rune)
- func (n *Link) IsMedia() bool
- func (n *Link) IsNaked() bool
- func (n *Link) IsNil() bool
- func (n *Link) IsPlain() bool
- func (n *Link) IsStandard() bool
- func (n *Link) Literal() string
- func (n *Link) String() string
- func (n *Link) Target() string
- func (n *Link) Text() string
- func (n *Link) TextToTitle()
- func (n *Link) Title() string
- type LinkType
- type ListError
- type Mention
- func (n *Mention) Clone() Elem
- func (n *Mention) Domain() string
- func (n *Mention) Err() error
- func (n *Mention) Format(state fmt.State, r rune)
- func (n *Mention) FormatAS(out io.Writer)
- func (n *Mention) FormatCompact(out io.Writer)
- func (n *Mention) FormatHTML(out io.Writer)
- func (n *Mention) FormatMarkdown(out io.Writer)
- func (n *Mention) FormatText(out io.Writer)
- func (n *Mention) IsNil() bool
- func (n *Mention) Literal() string
- func (n *Mention) Name() string
- func (n *Mention) SetTarget(target string)
- func (n *Mention) String() string
- func (n *Mention) Target() string
- func (n *Mention) Twter() types.Twter
- func (n *Mention) URL() *url.URL
- type NickForURLResolver
- type Salty
- type SaltyEvent
- type SaltyText
- type SaltyUser
- type Subject
- type Tag
- func (n *Tag) Clone() Elem
- func (n *Tag) CloneTag() *Tag
- func (n *Tag) Format(state fmt.State, r rune)
- func (n *Tag) FormatCompact(out io.Writer)
- func (n *Tag) FormatHTML(out io.Writer)
- func (n *Tag) FormatMarkdown(out io.Writer)
- func (n *Tag) FormatText(out io.Writer)
- func (n *Tag) IsNil() bool
- func (n *Tag) Literal() string
- func (n *Tag) String() string
- func (n *Tag) Target() string
- func (n *Tag) Text() string
- func (n *Tag) URL() (*url.URL, error)
- type Text
- type TokType
- type Token
- type Twt
- func (twt *Twt) Attrs() types.KV
- func (twt *Twt) Clone() types.Twt
- func (twt *Twt) CloneTwt() *Twt
- func (twt *Twt) Created() time.Time
- func (twt *Twt) Elems() []Elem
- func (twt *Twt) ExpandMentions(opts types.FmtOpts, lookup types.FeedLookup)
- func (twt *Twt) ExpandTags(opts types.FmtOpts, lookup types.FeedLookup)
- func (twt *Twt) FilePos() int
- func (twt *Twt) Format(state fmt.State, c rune)
- func (twt *Twt) FormatText(mode types.TwtTextFormat, opts types.FmtOpts) string
- func (twt *Twt) FormatTwt() string
- func (twt *Twt) GobDecode(data []byte) error
- func (twt *Twt) GobEncode() ([]byte, error)
- func (twt *Twt) Hash(options ...types.HashOption) string
- func (twt *Twt) IsNil() bool
- func (twt *Twt) IsZero() bool
- func (twt *Twt) Links() types.LinkList
- func (twt *Twt) Literal() string
- func (twt *Twt) LiteralText() string
- func (twt *Twt) MarshalJSON() ([]byte, error)
- func (twt *Twt) Mentions() types.MentionList
- func (twt *Twt) String() string
- func (twt *Twt) Subject() types.Subject
- func (twt *Twt) Tags() types.TagList
- func (twt *Twt) Text() string
- func (twt *Twt) Twter() types.Twter
Constants ¶
const EOF rune = -(iota + 1)
EOF represents an end of file.
Variables ¶
var ErrParseElm = errors.New("error parsing element")
var ErrParseToken = errors.New("error parsing digit")
Functions ¶
func NewTwtFile ¶
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
func (*Code) FormatMarkdown ¶
type Comment ¶
type Comment struct {
// contains filtered or unexported fields
}
func NewComment ¶
func NewCommentValue ¶
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
func (*DateTime) CloneDateTime ¶
type Elem ¶
type Elem interface { IsNil() bool // A typed nil will fail `elem == nil` We need to unbox to test. Literal() string // value as read from input. Clone() Elem // clone element. fmt.Formatter }
var LineSeparator Elem = &lineSeparator{}
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
func (*Link) IsStandard ¶
func (*Link) TextToTitle ¶
func (n *Link) TextToTitle()
type Mention ¶
type Mention struct {
// contains filtered or unexported fields
}
func NewMention ¶
func (*Mention) FormatCompact ¶
func (*Mention) FormatHTML ¶
func (*Mention) FormatMarkdown ¶
func (*Mention) FormatText ¶
type NickForURLResolver ¶
type NickForURLResolver interface { // NickForURL resolves the nickname for the given feed URI for a URL-only // mention in the form of '@<url>'. This way, it is possible to properly // render '@nick@domain' instead of '@domain@domain'. If unknown, an empty // string is returned, which then yields the fallback '@domain@domain' // form in the final rendering. NickForURL(uri string) string }
NickForURLResolver typically extends a types.FmtOpts by an additional, but optional NickForURL method.
type Salty ¶
type Salty interface { Literal() string // contains filtered or unexported methods }
func ParseSalty ¶
type SaltyEvent ¶
func NewSaltyEvent ¶
func NewSaltyEvent(cmd string, args ...string) *SaltyEvent
func (*SaltyEvent) Clone ¶
func (e *SaltyEvent) Clone() Elem
func (*SaltyEvent) IsNil ¶
func (e *SaltyEvent) IsNil() bool
func (*SaltyEvent) Literal ¶
func (s *SaltyEvent) Literal() string
type SaltyText ¶
type SaltyText struct { Timestamp *DateTime User SaltyUser Msg []Elem Mentions []*Mention Tags []*Tag Links []*Link Events []*SaltyEvent // contains filtered or unexported fields }
func (*SaltyText) LiteralText ¶
func (*SaltyText) MarshalJSON ¶
type SaltyUser ¶
func NewSaltyUser ¶
type Subject ¶
type Subject struct {
// contains filtered or unexported fields
}
func NewSubject ¶
func NewSubjectTag ¶
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
func (*Tag) FormatCompact ¶
func (*Tag) FormatHTML ¶
func (*Tag) FormatMarkdown ¶
func (*Tag) FormatText ¶
type TokType ¶
type TokType string
TokType passed to parser.
const ( TokILLEGAL TokType = "ILLEGAL" // Illegal UTF8 TokEOF TokType = "EOF" // End-of-File TokNUMBER TokType = "NUMBER" // Digit 0-9 TokLS TokType = "LS" // Unicode Line Separator TokNL TokType = "NL" // New Line TokSTRING TokType = "STRING" // String TokCODE TokType = "CODE" // Code Block TokSPACE TokType = "SPACE" // White Space TokTAB TokType = "TAB" // Tab TokSCHEME TokType = "://" // URL Scheme TokCOLON TokType = ":" TokHYPHEN TokType = "-" TokDOT TokType = "." TokPLUS TokType = "+" TokT TokType = "T" TokZ TokType = "Z" TokHASH TokType = "#" TokEQUAL TokType = "=" TokAT TokType = "@" TokLT TokType = "<" TokGT TokType = ">" TokLPAREN TokType = "(" TokRPAREN TokType = ")" TokLBRACK TokType = "[" TokRBRACK TokType = "]" TokBANG TokType = "!" TokBSLASH TokType = `\` TokSQUOTE TokType = "'" TokDQUOTE TokType = `"` )
TokType values
type Twt ¶
type Twt struct {
// contains filtered or unexported fields
}
func (*Twt) ExpandMentions ¶
func (twt *Twt) ExpandMentions(opts types.FmtOpts, lookup types.FeedLookup)
ExpandMentions will take a list of mentions and replace the `target` field with the URL of the user if the mention is a valid user in the lookup table. If the mention is not a valid user, or if the lookup table is nil, the `target` field is left blank. If the mention is a valid user, but the lookup table is not nil, the `target` field is replaced with the URL of the user. This is useful for turning plain text mentions into links to the user's profile.
func (*Twt) ExpandTags ¶
func (twt *Twt) ExpandTags(opts types.FmtOpts, lookup types.FeedLookup)
func (*Twt) FormatText ¶
FormatText formats the Twt according to the given mode and returns the formatted string.
Available modes are:
- types.ASFmt: Format as a string representation of the Twt's elements.
- types.HTMLFmt: Format as HTML.
- types.TextFmt: Format as plain text.
- types.MarkdownFmt: Format as Markdown.
If opts is non-nil, it is used to perform additional formatting such as expanding mentions and tags, and rewriting URLs. When it implements the optional interface NickForURLResolver it is called to resolve nicks for URL-only mentions in the form of '@<url>'.
func (*Twt) LiteralText ¶
func (*Twt) MarshalJSON ¶
func (*Twt) Mentions ¶
func (twt *Twt) Mentions() types.MentionList