htmltotext

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

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

Go to latest
Published: Jun 4, 2018 License: MPL-2.0 Imports: 7 Imported by: 1

README

html-to-text

Build status Go Report Card Coverage Status

Purpose

Converts html to text. I built this so that I could use it to convert the html in rss feeds to text that can be displayed in the terminal for go-rss-reader.

Documentation

Index

Constants

View Source
const (
	//OpenDivTag -- Open html div tag
	OpenDivTag = Tag("<div")
	//CloseDivTag -- Close html div tag
	CloseDivTag = Tag("</div>")

	//OpenH1Tag -- Open html h1 tag
	OpenH1Tag = Tag("<h1")
	//CloseH1Tag -- Closed html h1 tag
	CloseH1Tag = Tag("</h1>")

	//OpenH2Tag -- Open html h2 tag
	OpenH2Tag = Tag("<h2")
	//CloseH2Tag -- Close html h2 tag
	CloseH2Tag = Tag("</h2>")

	//OpenH3Tag -- Open html h3 tag
	OpenH3Tag = Tag("<h3")
	//CloseH3Tag -- Close html h3 tag
	CloseH3Tag = Tag("</h3>")

	//OpenH4Tag -- Open html h4 tag
	OpenH4Tag = Tag("<h4")
	//CloseH4Tag -- Close html h4 tag
	CloseH4Tag = Tag("</h4>")

	//OpenH5Tag -- Open html h5 tag
	OpenH5Tag = Tag("<h5")
	//CloseH5Tag -- Close html h5 tag
	CloseH5Tag = Tag("</h5>")

	//OpenH6Tag -- Open html h6 tag
	OpenH6Tag = Tag("<h6")
	//CloseH6Tag -- Close html h6 tag
	CloseH6Tag = Tag("</h6>")

	//OpenPTag -- Open html p tag
	OpenPTag = Tag("<p")
	//ClosePTag -- Closed html p tag
	ClosePTag = Tag("</p>")

	//OpenOLTag -- Open html ordered list tag
	OpenOLTag = Tag("<ol")
	//CloseOLTag -- Close html ordered list tag
	CloseOLTag = Tag("</ol>")

	//OpenULTag -- Open html unordered list tag
	OpenULTag = Tag("<ul>")
	//CloseULTag -- Closed html unordered list tag
	CloseULTag = Tag("</ul>")

	//OpenLITag -- Open html list tag
	OpenLITag = Tag("<li>")
	//CloseLITag -- Close html list tag
	CloseLITag = Tag("</li>")

	//OpenATag -- Open html a tag
	OpenATag = Tag("<a")
	//CloseATag -- Close html a tag
	CloseATag = Tag("</a>")

	//OpenTableTag -- Open html table tag
	OpenTableTag = Tag("<table")
	//CloseTableTag -- Close html table tag
	CloseTableTag = Tag("</table>")

	//OpenTRTag -- Open html tr tag
	OpenTRTag = Tag("<tr")
	//CloseTRTag -- Close html tr tag
	CloseTRTag = Tag("</tr>")

	//OpenTHeadTag -- Open html thead tag
	OpenTHeadTag = Tag("<thead")
	//CloseTHeadTag -- Close html thead tag
	CloseTHeadTag = Tag("</thead>")

	//OpenTHTag -- Open html th tag
	OpenTHTag = Tag("<th")
	//CloseTHTag -- Close html th tag
	CloseTHTag = Tag("</th>")

	//OpenTDTag -- Open html td tag
	OpenTDTag = Tag("<td")
	//CloseTDTag -- Close html td tag
	CloseTDTag = Tag("</td>")

	//OpenStyleTag -- Open html style tag
	OpenStyleTag = Tag("<style>")
	//CloseStyleTag -- Close html style tag
	CloseStyleTag = Tag("</style>")

	//OpenHeadTag -- Open html head tag
	OpenHeadTag = Tag("<head>")
	//CloseHeadTag -- Close html head tag
	CloseHeadTag = Tag("</head>")

	//BreakTag -- html br tag
	BreakTag = Tag("<br")

	//ImageTag -- html img tag
	ImageTag = Tag("<img")
)

Variables

This section is empty.

Functions

func Translate

func Translate(reader io.Reader) (string, []string, error)

Translate -- translates html to text

Types

type Stack

type Stack []Tag

Stack -- A stack used when processing the html tags during the translation from html to text

func NewStack

func NewStack() (s Stack)

NewStack -- Returns an empty Stack

func (Stack) Contains

func (s Stack) Contains(tags ...Tag) bool

Contains -- Checks to see if a Tag is in the Stack

func (Stack) OnTop

func (s Stack) OnTop(t Tag) bool

OnTop -- Checks if the wanted Tag is on Top

func (Stack) Peek

func (s Stack) Peek() (t Tag, err error)

Peek -- Peeks at the Tag on top of the stack

func (Stack) Pop

func (s Stack) Pop() (Stack, Tag, error)

Pop -- Pops a Tag off of the stack

func (Stack) Push

func (s Stack) Push(t Tag) Stack

Push -- Pushes a Tag onto the stack

type Tag

type Tag string

Tag -- A struct for HTML tags

func (Tag) Byte

func (t Tag) Byte() []byte

Byte -- returns the tag in a slice of bytes

func (Tag) String

func (t Tag) String() string

Jump to

Keyboard shortcuts

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