html2text

package module
v0.0.0-...-7adf2c8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2017 License: MIT Imports: 3 Imported by: 3 modules, 2 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.

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
*/

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 HTML2TextCustomLine

func HTML2TextCustomLine(html, newline string) string

HTML2TextNewCustomLine converts html into a text form with custom line endings

func HTMLEntitiesToText

func HTMLEntitiesToText(htmlEntsText string) string

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

Types

This section is empty.

Directories

Path Synopsis
cmd
html2text command

Jump to

Keyboard shortcuts

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