html2text

package module
v0.0.0-...-aef00b9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: MIT Imports: 3 Imported by: 1

README

GoDoc Build Status Coverage Status Report Card

html2text

A simple Golang package to convert HTML to plain text.

It converts HTML tags to text and also parses HTML entities into characters they represent. A header section of the HTML document is stripped out, most tags are stripped but links are properly converted into their href attribute.

It can be used for converting HTML emails into text.

Some tests are installed as well.

Fell free to publish a pull request if you have suggestions for improvement.

Install

go get github.com/k3a/html2text

Usage

package main

import (
	"fmt"
	"github.com/k3a/html2text"
)

func main() {
	html := `<html><head><title>Good</title></head><body><strong>clean</strong> text</body>`
	
	plain := html2text.HTML2Text(html)
			  
	fmt.Println(plain)
}

/*	Outputs:

	clean text
*/

Alternatives

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML2Text

func HTML2Text(html string) string

HTML2Text converts html into a text form

func HTMLEntitiesToText

func HTMLEntitiesToText(htmlEntsText string) string

HTMLEntitiesToText decodes HTML entities inside a provided string and returns decoded text

Types

This section is empty.

Jump to

Keyboard shortcuts

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