gohtml: github.com/yosssi/gohtml Index | Files

package gohtml

import "github.com/yosssi/gohtml"

Package gohtml provides an HTML formatting function.

Index

Package Files

consts.go doc.go element.go formatter.go html_document.go parser.go tag_element.go text_element.go utils.go writer.go

Variables

var Condense bool

Enable condensing a tag with only inline children onto a single line, or completely inlining it with sibling nodes. Tags to be treated as inline can be set in `InlineTags`. Only inline tags will be completely inlined, while other condensable tags will be given their own dedicated (single) line.

var InlineTagMaxLength = 40

Maximum length of an opening inline tag before it's un-inlined

var InlineTags = map[string]bool{
    "a":      true,
    "code":   true,
    "em":     true,
    "span":   true,
    "strong": true,
}

Tags that are considered inline tags. Note: Text nodes are always considered to be inline

var IsPreformatted = func(token html.Token) bool {
    return token.Data == "pre" || token.Data == "textarea"
}

Function that identifies which tags will be treated as containing preformatted content. Such tags will have the formatting of all its contents preserved unchanged. The opening tag html.Token is passed to this function. By default, only <pre> and <textarea> tags are considered preformatted.

var LineWrapColumn = 0

Column to wrap lines to (disabled by default)

var LineWrapMaxSpillover = 5

Maxmimum characters a long word can extend past LineWrapColumn without wrapping

func AddLineNo Uses

func AddLineNo(s string) string

func Format Uses

func Format(s string) string

Format parses the input HTML string, formats it and returns the result.

func FormatBytes Uses

func FormatBytes(b []byte) []byte

FormatBytes parses input HTML as bytes, formats it and returns the result.

func FormatWithLineNo Uses

func FormatWithLineNo(s string) string

Format parses the input HTML string, formats it and returns the result with line no.

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields
}

A Writer represents a formatted HTML source codes writer.

func NewWriter Uses

func NewWriter(wr io.Writer) *Writer

NewWriter generates a Writer and returns it.

func (*Writer) SetLastElement Uses

func (wr *Writer) SetLastElement(lastElement string) *Writer

SetLastElement set the lastElement to the Writer.

func (*Writer) Write Uses

func (wr *Writer) Write(p []byte) (n int, err error)

Write writes the parameter.

Package gohtml imports 7 packages (graph) and is imported by 18 packages. Updated 2020-05-19. Refresh now. Tools for package owners.