Documentation
¶
Overview ¶
Package sections models the individual multipart sections of an MHT file: their headers, decoded bodies, and re-encoding on output.
Index ¶
- func QuotedPrintableEncode(input string) (string, error)
- func Scan(scanner *bufio.Scanner, boundary string, section *Section) error
- type Section
- func (section *Section) Image() (image.Image, string, error)
- func (section *Section) ImageBytes() ([]byte, error)
- func (section *Section) IsBase64() bool
- func (section *Section) IsQuotedPrintable() bool
- func (section *Section) ReplaceImage(contentType, contentEncoding string, imageBytes []byte) error
- func (section *Section) Write(writer io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuotedPrintableEncode ¶
QuotedPrintableEncode encodes input in quoted-printable format.
func Scan ¶
Scan reads one section (headers and body) from scanner into section. It assumes the opening boundary has already been consumed. Scan returns nil when it stops at an intermediate boundary and io.EOF when it stops at the closing boundary or the end of input; in both cases the section is valid.
Types ¶
type Section ¶
type Section struct {
Headers textproto.MIMEHeader `json:"headers"`
Body string `json:"content"`
}
Section is a single multipart section. Body holds the decoded content: text for quoted-printable sections, the undecoded base64 string (without line breaks) for base64 sections.
func (*Section) Image ¶
Image decodes the section body as an image, returning the image and the format name reported by image.Decode (e.g. "png").
func (*Section) ImageBytes ¶
ImageBytes returns the section body decoded from base64 into raw image bytes.
func (*Section) IsQuotedPrintable ¶
IsQuotedPrintable reports whether the section body is quoted-printable encoded. A missing Content-Transfer-Encoding counts as quoted-printable, since some ingestion paths strip the header.
func (*Section) ReplaceImage ¶
ReplaceImage replaces the section's content with imageBytes, updating the Content-Type and Content-Transfer-Encoding headers. If contentEncoding is "base64" the bytes are encoded; otherwise they are stored verbatim.