Documentation ¶
Overview ¶
Package gohtml provides an HTML formatting function.
Index ¶
Constants ¶
This section is empty.
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 (
DefaultIndentString = " "
)
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
Functions ¶
func FormatBytes ¶
FormatBytes parses input HTML as bytes, formats it and returns the result.
func FormatWithLineNo ¶
Format parses the input HTML string, formats it and returns the result with line no.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer represents a formatted HTML source codes writer.
func (*Writer) SetLastElement ¶
SetLastElement set the lastElement to the Writer.