Skip to content

feat: add ConvertReader for documents read from an io.Reader - #83

Merged
hownowstephen merged 1 commit into
mainfrom
feat_convert_reader
Sep 23, 2026
Merged

hownowstephen merged 1 commit into
mainfrom
feat_convert_reader

Conversation

@hownowstephen

Copy link
Copy Markdown
Contributor

ConvertReader(r io.Reader, opts ...Option) converts a document straight from a reader. Convert now wraps it with a strings.Reader.

text, err := textplain.ConvertReader(part, textplain.WithLinks(textplain.LinksFootnotes))

A mail pipeline usually has the HTML part as a reader, such as a MIME part or a decoded transfer encoding. Callers no longer need to read it into a string first, because html.Parse already consumes a reader.

This also brings coverage to 100%. The html.Parse error return was the last uncovered statement, since a strings.Reader never fails, and now a failing reader reaches it. TestConvertReader uses iotest.ErrReader to check that read errors come back unchanged.

The change is additive, and Convert's signature and behaviour are the same. The README mentions ConvertReader under Usage.

@hownowstephen
hownowstephen marked this pull request as ready for review September 23, 2026 04:41
@hownowstephen
hownowstephen merged commit 6ede60f into main Sep 23, 2026
2 checks passed
@hownowstephen
hownowstephen deleted the feat_convert_reader branch September 23, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant