go-emailthreads – git.sr.ht/~emersion/go-emailthreads Index | Files | Directories
Deprecated: this module is unmaintained.

package emailthreads

import "git.sr.ht/~emersion/go-emailthreads"

Index

Types

type Block

type Block struct {
	// Replies to this block.
	Children []*Block

	// The message this block comes from.
	Source *Message
	// The region of this block's text in the source message.
	SourceStart, SourceEnd int

	// If this block is a reply to a particular chunk of the parent block,
	// ParentStart and ParentEnd indicate the region in the parent's body.
	// Otherwise, they are set to -1. ParentStart is an inclusive offset and
	// ParentEnd is an exclusive offset.
	ParentStart, ParentEnd int
}

Block is a block of text in the thread.

Blocks are parts of a message's body that aren't quotes of the parent message. A block can be a reply to a parent block, in which case the ParentStart and ParentEnd fields indicate which part of the parent message is replied to. A block can have replies, each of which will be represented by a block in the Children field.

func Parse

func Parse(msgs []Message) ([]*Block, error)

Parse builds a tree of blocks from a thread.

On success, it will always return a non-empty slice. The first element is the root block (whose body matches exactly the root message's). Subsequent blocks are chunks of child messages which aren't replies to another specific block.

func (*Block) Body

func (block *Block) Body() string

Body returns the block's plain-text content.

type Message

type Message struct {
	Header mail.Header
	Body   string
}

Message is a mail message used as input data for this package.

Source Files

block.go canonicalize.go emailthreads.go

Directories

PathSynopsis
cmd
cmd/emailthreads-parse
Version
v0.0.0-20240517084723-b22139dc7e17 (latest)
Published
May 17, 2024
Platform
linux/amd64
Imports
5 packages
Last checked
1 week ago

Tools for package owners.