html

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: Apache-2.0 Imports: 4 Imported by: 6

README

HTML 🤓

GoDoc Build Status Codecov Go Report Card Version

Simple Go (golang) library for manipulating HTML content

FromText(text) html

ToText(html) text

IsHTML(string) bool

RemoveTags(html) string

Summary(html) string

CollapseWhitespace(string) string

Pull Requests Welcome

Original versions of this library have been used in production on commercial applications for years, and the extra data collection has been a tremendous help for everyone involved.

I'm now open sourcing this library, and others, with hopes that you'll also benefit from a more robust error package.

Please use GitHub to make suggestions, pull requests, and enhancements. We're all in this together! 🤪

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseWhitespace

func CollapseWhitespace(text string) string

CollapseWhitespace converts all whitespace characters into a single SPACE character

func FromText

func FromText(text string) string

FromText converts plain text into (lightly) formatted HTML

func IsHTML

func IsHTML(html string) bool

IsHTML returns TRUE if the string provided "looks like" HTML, in that, it has one or more substrings that appear to be an HTML tag

func RemoveTags

func RemoveTags(html string) string

RemoveTags aggressively strips HTML tags from a string. It will only keep anything between `>` and `<`. From: https://stackoverflow.com/questions/55036156/how-to-replace-all-html-tag-with-empty-string-in-golang Original code by: Daniel Morell <https://stackoverflow.com/users/10463261/daniel-morell>

func Summary

func Summary(html string) string

Summary returns the first few sentences of content from an HTML document

func ToText

func ToText(html string) string

ToText returns a string that has been converted from HTML into plain text. Mostly, this means replacing block level tags (BR, P, DIV) with carriage returns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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