message_text

package
v1.103.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package message_text reads a Gmail message as text: its text/plain part, or, failing one, its text/html part read by a reader of HTML the caller gives, as github.com/altshiftab/html_text's Text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data string) ([]byte, error)

Decode decodes data as Gmail serves it, base64url-encoded, with or without padding.

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 Text

func Text(msg *message.Message, htmlToText func(source string) string) string

Text is the text of the message: its text/plain part, or, failing one, its text/html part read as text by htmlToText, which also reads a text/plain part that is an HTML document in fact, as some senders' are. A message with neither -- an image, a calendar invitation with no description -- has none, and nor has one of HTML alone when htmlToText is nil. A text/plain part keeps its indentation and its runs of spaces, which line its columns up.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL