htmlrtf

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package htmlrtf de-encapsulates HTML from RTF that encapsulates it, as Outlook stores HTML mail ([MS-OXRTFEX]): the document declares \fromhtml1 in its header, the HTML's markup is in {\*\htmltagN ...} groups, the HTML's text is between them, and \htmlrtf ... \htmlrtf0 runs hold an RTF-only rendering that is skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Charset

func Charset(cp int) string

Charset returns the WHATWG label of a code page, or "" when it has none.

Types

type Result

type Result struct {
	// Found: the document declares \fromhtml1 in its header.
	Found bool
	// HTML is the de-encapsulated HTML, in the code page CodePage. It is
	// empty when Found is false or when Cut is true.
	HTML     []byte
	CodePage int
	// Cut: the HTML is longer than the limit and was not kept.
	Cut bool
}

Result is what Extract found.

func Extract

func Extract(ctx context.Context, src io.Reader, limit int64, maxDepth int) (Result, error)

Extract reads src, an RTF document from its opening brace. When the header declares \fromhtml1 it returns the encapsulated HTML, as long as it is at most limit bytes; past that it stops and sets Cut. Groups nested deeper than maxDepth are not read. Reading stops, without Found, at the first content of a document that does not declare \fromhtml1.

Jump to

Keyboard shortcuts

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