Documentation
¶
Overview ¶
Package message_text reads a Gmail message as text: its text/plain part, or, failing one, its text/html part with the markup taken out.
Index ¶
- func Decode(data string) ([]byte, error)
- func FindTextPart(part *message_part.MessagePart, mimeType string) *message_part.MessagePart
- func HtmlToText(source string) string
- func NormalizeWhitespace(text string) string
- func Text(msg *message.Message) string
- func TextWith(msg *message.Message, htmlToText func(source string) string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindTextPart ¶
func FindTextPart(part *message_part.MessagePart, mimeType string) *message_part.MessagePart
FindTextPart returns the first part of the mime type that is text rather than an attachment, searching the parts in the order they appear. A message that is not multipart is its own single part.
func HtmlToText ¶
HtmlToText is the text a page would show, near enough to read: what is not shown is dropped, a link keeps its target, what breaks the line breaks it, the tags go, and the entities come back as the characters they stand for.
func NormalizeWhitespace ¶
NormalizeWhitespace is a text with one space between words, no trailing space on a line, and no more than one blank line in a row.
func Text ¶
Text is the text of the message: its text/plain part, or, failing one, its text/html part read as text. A message with neither -- an image, a calendar invitation with no description -- has none.
Gmail serves a part's data in the message's own character set, which for mail is overwhelmingly UTF-8; what is not valid UTF-8 is read as Latin-1, which is right for the rest of what arrives and readable for anything else.
Types ¶
This section is empty.