Skip to content

pspeter3/emailreplyparser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Reply Parser for Go

Build Status Coverage GoDoc

A Go port of GitHub's Email Reply Parser library. The library is used to strip away non essential content from email bodies. An example use case is to allow email replies to comments without including signatures or extra noise.

Installation

To install emailreplyparser run the standard installation:

go get github.com/recapco/emailreplyparser

Usage

The library can be used to get the essential text of body with following example:

reply, err := emailreplyparser.ParseReply(emailBody)

The library can also be used to retrieve the signature. For example:

func Signature(text string) (string, error) {
	email, err := emailreplyparser.Read(text)
	if err != nil {
		return "", err
	}
	for _, fragment := range email.Fragments {
		if fragment.Signature {
			return fragment.String(), nil
		}
	}
	return "", nil
}

The library can also help discover quotes in an email. For example:

func Quotes(text string) ([]string, error) {
	email, err := emailreplyparser.Read(text)
	if err != nil {
		return [], err
	}
	var quotes []string
	for _, fragment := range email.Fragments {
		if fragment.Quoted {
			quotes = append(quotes, fragment.String())
		}
	}
	return quotes, nil
}

Building and Testing

Building and testing follow the normal Go conventions of go build and go test.

Contributing

Please feel to submit Pull Requests and Issues.

License

MIT

About

A Go port of GitHub's Email Reply Parser library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%