reply

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 6 Imported by: 0

README

go.dev reference Go Report Card

reply

Library to trim replies from plain text email. (Golang port of https://github.com/discourse/email_reply_trimmer)

Forked from https://github.com/dimiro1/reply

Why

Reply was forked because the original project does not seem to be maintained. Furthermore, the version before the fork removes parts of the mail that should not be removed. The project was forked to change this.

Usage

package main

import (
    "fmt"

    "code.forgejo.org/forgejo/reply"
)

func main() {
    message := `
        This is before the embedded email.
        
        On Wed, Sep 25, 2013, at 03:57 PM, richard_clark wrote:
        
        Richard> This is the embedded email
        
        This is after the embedded email and will not show up because 99% of the times
        this is the signature...
    `
	fmt.Println(reply.FromText(message))
}

will output:

This is before the embedded email.

Documentation

Overview

Package reply package is essentially a source code conversion of the ruby library https://github.com/discourse/email_reply_trimmer. The core logic is a almost line by line conversion.

This package has a dependency on excellent regex library github.com/dlclark/regexp2. The reason for not using the standard regex library was due to the fact that the regex package from the stdlib is not compatible with the library from the Ruby stdlib.

All the tests were taken from the email_reply_trimmer library.

Note: This code is not idiomatic go code, as, it was mostly adapted from the ruby code, however, the public APIs were kept simple as possible and does not expose any internal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromReader

func FromReader(reader io.Reader) (string, error)

FromReader returns the reply text from the e-mail text body.

func FromText

func FromText(text string) string

FromText returns the reply text from the e-mail text body.

Types

This section is empty.

Jump to

Keyboard shortcuts

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